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


PowerShell in Depth

Path

Pipe

Comment

Value Types

String

Variable

Boolean

Conditional

Data Structure

Loop and Iteration

Input/Output

Function

Profile and Script

Script Examples

Misc