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 | |
---|---|
Result | Boolean representation |
| True |
| False |
| False |
Nonzero number | True |
Zero | False |
Nonempty string | True |
Empty string | False |
Nonempty array | True |
Empty array | False |
Hashtable (either empty or not) | True |
3.141.202.187