Windows Vista Forums

Prevent Output

  1. #1


    ryanlsanders@gmail.com Guest

    Prevent Output

    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 System SpecsSystem Spec

  2. #2


    Keith Hill [MVP] Guest

    Re: Prevent Output

    <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 System SpecsSystem Spec

  3. #3


    dreeschkind Guest

    RE: Prevent Output

    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 System SpecsSystem Spec

  4. #4


    RichS Guest

    RE: Prevent Output

    $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 System SpecsSystem Spec

  5. #5


    klumsy@xtra.co.nz Guest

    Re: Prevent Output


    > $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 System SpecsSystem Spec


Prevent Output
Similar Threads
Thread Forum
Prevent DLL from being referenced .NET General
Enexpected output when using output-csv PowerShell
How to prevent thumbnails Software
How do I prevent ..... Vista mail
No output from write-output PowerShell