Q. What does null mean in PowerShell?

Don Jones

May 10, 2010

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. In PowerShell, you’ll see \[null\] used in commands like this:

\[null\] \[System.Reflection.Assembly\]::LoadWithPartialName("System.Windows.Forms")

This was especially common in PowerShell 1.0. It reflects the fact that there are many ways to do things in PowerShell, and some of those ways have a software developer twist to them, like this one. Basically, this is executing the command:

 \[System.Reflection.Assembly\]::LoadWithPartialName("System.Windows.Forms")

It then casts the result (which will usually be some kind of success indicator) as a “null” data type. The practical effect of this is to suppress the output. A more command-line oriented version of this technique is to pipe the output to Out-Null:

 \[System.Reflection.Assembly\]::LoadWithPartialName("System.Windows.Forms") | Out-Null

Both have exactly the same effect.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like