Powershell Best Practice #12: Avoid Out-Null cmdlet

By | June 28, 2015

Best Practice: It is recommended to avoid Out-Null when you need to suppress the output of some commands inside large loops (for, foreach, etc.) for example.


It is recommended to assign to $null or [void] casting for better performance.

When you want to suppress the output of a command (example: when adding items to a collection), using Out-Null is slow.

Results of a test with a large loop:

measure null powershell


Leave a Reply

Your email address will not be published.