4 ways to send output to NULL in PowerShell

Often you will be in situations when you want to perform an operation at the same time suppress any output sent to the PowerShell console.

Best use case could be when creating a new directory an output is sent to the console with the name, size, time and other details. In some scripting scenarios you won’t be willing to see this output on the console and send it to NULL.

Like, creating a temporary file/directory during the script execution which may mess up the desired/custom script output on the console


or, loading assemblies in the PowerShell script like in the following screenshot which outputs the success indication once the assembly has been loaded.


Following are 4 methods to send output to null and suppress these outputs in the console –

  1. Using Out-Null Cmdlet : Hides/discards the output instead of sending it down the pipeline or displaying it.1
  2. Typecasting to [void] : This is more of a very C#-flavored trick

  3. Redirection to $NULL:  Redirecting the output to the Automatic variable $Null

  4. Assignment to $NULL: Assigning the output to the Automatic variable $Null1

NOTE: The performance vary in all 4 approaches, in the following screenshot you can clearly see the difference. Using Out-Null is the slowest but, the usage of Automatic variable $NULL is faster compared to other approaches.


Please do follow me on twitter and thanks for reading. Cheers! 😉




My new book :  PowerShell Scripting Guide to Python


This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.

“Use what you know to learn what you don’t. ” also known as Associative learning.

Book follows a comparative method to jump start readers journey in Python, but who is the target audience? and who should read this book –

  • Any System Administrator who want to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
  • Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.

Python is one of the top programming languages and in fast changing IT scenarios to DevOps and Cloudto the future – Data ScienceArtificial Intelligence (AI) and Machine Learning Python is a must know.

But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell

NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!

While the book is in progress, please review it and send any feedback or error corrections at prateek@ridicurious.com



2 thoughts on “4 ways to send output to NULL in PowerShell

  1. So using the old DOS redirection > is way faster then using the shinny new PS pipeline to Out-Null cmdlet. Who’d a thunk it. 😉


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s