Q. What does null mean in PowerShell?

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.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish