Send output to null, delete output instead of sending it to the console.

      Out-Null [-inputObject psobject] [CommonParameters]

   -inputObject psobject
       The object that will be sent to null (deleted). {may be piped}
       A command, expression or variable that contains the objects.

The final part of displaying PowerShell output is a hidden background call to an Output cmdlet, by default as the last part of the execution process PowerShell calls the default output cmdlet which is typically Out-Host.

When running an external Windows .EXE executable from a PowerShell script, by default the script will not wait and will immediately continue to the next command. Piping the command to out-null or out-default will force PowerShell to wait for the process to exit before continuing.
An alternative method of doing this is Start-Process -wait program.exe


Discarding output that you don’t need:

PS C:\> get-childitem | out-null

Run an executable and wait for it to complete:

PS C:\> Notepad.exe | Out-Null

An alternative method, is to use the $null automatic variable, this may be faster if no pipeline is involved:

PS C:\> get-childitem > $null
PS C:\> $null = get-childitem

Another alternative, is to use the [void] cast:

PS C:\> [void] (get-childitem)

“Being unwanted, unloved, uncared for, forgotten by everybody, I think that is a much greater hunger, a much greater poverty than the person who has nothing to eat . . . . We must find each other” ~ Mother Teresa

Related PowerShell Cmdlets

Out-Default - Send output to default.
Out-File - Send command output to a file.
Out-GridView - Send output to an interactive table.
Out-Host - Send the pipelined output to the host.
Out-Printer - Send the output to a printer.
Out-String - Send output to the pipleline as strings.
Tee-Object - Send input objects to two places.
Equivalent bash command: redirection - Redirection and Process Substitution.

Copyright © 1999-2024 SS64.com
Some rights reserved