• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Prevent Output

  • Thread starter ryanlsanders@gmail.com
  • Start date
R

ryanlsanders@gmail.com

#1
I have this script (yes I am using some stuff from Quest)

$VAR = 0
while ($VAR -ne 10)
{
$VAR++
New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name
"Test User$var"
}


How can I prevent the script from showing a line for each user added.
I just want a output line when the script has run.
 

My Computer

K

Keith Hill [MVP]

#2
<ryanlsanders@gmail.com> wrote in message
news:1180555213.973716.171960@q69g2000hsb.googlegroups.com...
>I have this script (yes I am using some stuff from Quest)
>
> $VAR = 0
> while ($VAR -ne 10)
> {
> $VAR++
> New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name
> "Test User$var"
> }
>
>
> How can I prevent the script from showing a line for each user added.
> I just want a output line when the script has run.
>


You have a couple of options:

$results = New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name
"Test User$var"

if you want to keep the output of this cmdlet. If you don't want the output
at all then you could also do this:

New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name "Test
User$var" > $null

--
Keith
 

My Computer

D

dreeschkind

#3
Piping to out-null should do the trick:

$VAR = 0
while ($VAR -ne 10)
{
$VAR++
New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name "Test
User$var" | out-null
}

--
greetings
dreeschkind

"ryanlsanders@gmail.com" wrote:

> I have this script (yes I am using some stuff from Quest)
>
> $VAR = 0
> while ($VAR -ne 10)
> {
> $VAR++
> New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name
> "Test User$var"
> }
>
>
> How can I prevent the script from showing a line for each user added.
> I just want a output line when the script has run.
>
>
 

My Computer

R

RichS

#4
$null = New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name
"Test User$var"

should work as well

--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"dreeschkind" wrote:

> Piping to out-null should do the trick:
>
> $VAR = 0
> while ($VAR -ne 10)
> {
> $VAR++
> New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name "Test
> User$var" | out-null
> }
>
> --
> greetings
> dreeschkind
>
> "ryanlsanders@gmail.com" wrote:
>
> > I have this script (yes I am using some stuff from Quest)
> >
> > $VAR = 0
> > while ($VAR -ne 10)
> > {
> > $VAR++
> > New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name
> > "Test User$var"
> > }
> >
> >
> > How can I prevent the script from showing a line for each user added.
> > I just want a output line when the script has run.
> >
> >
 

My Computer

K

klumsy@xtra.co.nz

#5

> $VAR = 0
> while ($VAR -ne 10)
> {
> $VAR++
> [void] ( New-QADUser -ParentContainer 'OU=Test,DC=domain,DC=local' -Name "Test User$var" )
>
> }
>


casting to void works.. here being a cmdlet you gotta put the
expression in a ()

but if its say just a method on a dotnet object you could do

[void]$a.additem()
 

My Computer