Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

1.6. Booleans

Boolean (true or false) variables are most commonly initialized to their literal values of $true and $false. When it evaluates them as part of a Boolean expression (i.e., an “if” statement,) though, PowerShell maps results into a suitable Boolean representation.

Windows PowerShell Boolean interpretations
ResultBoolean representation
$trueTrue
$falseFalse
$nullFalse
Nonzero numberTrue
ZeroFalse
Nonempty stringTrue
Empty stringFalse
Nonempty arrayTrue
Empty arrayFalse
Hashtable (either empty or not)True



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial