How to Hide a Command's Output in PowerShell with Out-Null
Some PowerShell commands print something you didn't ask for. Adding an item to an ArrayList, for example, prints the item's position. Piping the command to Out-Null throws that output away. This guide shows the difference, with real output from PowerShell 7.6.10.
Syntax
<command> | Out-Null
| Part | What it means |
|---|---|
<command> | Runs as usual, side effects included |
| Out-Null | Receives its output and discards it |
The reference: "The Out-Null cmdlet sends its output to NULL, in effect, removing it from the pipeline and preventing the output from being displayed on screen."
Prerequisites
- PowerShell 7. This guide uses PowerShell 7.6.10.
Step 1: Add Two Names, One Quietly
$list = [System.Collections.ArrayList]::new()
$list.Add("Ada")
$list.Add("Grace") | Out-Null
"The list has $($list.Count) names."
0
The list has 2 names.

The first Add printed 0, the position of Ada. The second added Grace just the same, but Out-Null swallowed its 1.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Piping to Out-Null to hide errors | Errors don't go through the pipeline: Get-Content missing.txt | Out-Null still printed Cannot find path ... | Handle them with try and catch, or redirect the error stream |
| Using it where you need the output later | The output is gone | Store it in a variable instead |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Stray numbers appear in a script's output | A method such as ArrayList.Add returns a value, and PowerShell prints it | Add | Out-Null to that line |
FAQ
Are there other ways to discard output?
Yes: > $null, [void] before the expression and $null = ... all discard it too. With one name added each way, the list ended with 3 names and nothing else was printed.
Does Out-Null stop the command from running?
No. The command runs fully; only its output is thrown away, as the list's count of 2 shows.
Conclusion
$list.Add("Grace") | Out-Null added the name without printing its index, while the first Add printed 0. Use it on any line whose output you don't need.
Additional Resources
- Out-Null — the cmdlet.
- about_Redirection — redirecting to
$null.
