PowerShell: True/False (boolean)

By Xah Lee. Date: . Last updated: .

Whenever you need boolean, use $true or $false. They are Automatic Variables.

PowerShell True/False Interpretation
ValueValue in Boolean Context
$trueTrue
Nonzero numberTrue
Nonempty StringTrue
Nonempty ArrayTrue
Hashtable (empty or not)True
$falseFalse
$nullFalse
ZeroFalse
Empty StringFalse
Empty ArrayFalse

PowerShell Operators