Out-Null

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

Syntax
      Out-Null [-inputObject psobject] [CommonParameters]

Key

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

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

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.

Example

Discarding output that you don't need:

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

An alternative method, which runs much faster is to use the $null automatic variable:

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

Another alternative, which also runs much faster 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 © SS64.com 1999-2019
Some rights reserved