Out Null - PowerShell


Out-Null is a PowerShell command used to suppress the output of another command or script. It acts as a placeholder receiver, discard all data sent to it, and allows the execution of commands or scripts without displaying their output on the console.


Out-Null [-InputObject] <object>


  • InputObject: This optional parameter specifies the input data to be passed to the command or script before suppressing its output.




Example 1: Suppressing Output of a Command

Get-ChildItem C:\ | Out-Null

This command gets all the child items in the C:\ directory, but suppresses their output.

Example 2: Using InputObject to Process Data

Get-Service | ForEach-Object { $_.Name } | Out-Null

This command gets all the services on the system, retrieves their names, and then suppresses their output.

Common Issues

Issue: The Out-Null command does not suppress the output of certain commands, such as Write-Host.

Solution: To suppress the output of commands like Write-Host, use the -NoNewline parameter instead of Out-Null.


Integration with Other Commands:

  • Tee-Object: Used together with Tee-Object, Out-Null can capture the output of a command and send it to a file while simultaneously suppressing its display on the console.

Integration with Scripts:

  • Error Handling: Out-Null can be used in combination with error handling to suppress the output of error messages.
  • Data Filtering: Out-Null can be used to filter data by passing it as the input to another command or script that processes and filters the data.