PowerShell: True/False (boolean)

By Xah Lee. Date: . Last updated: .

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

If you just type “True” in PowerShell, it's a error, because its invalid command or expression. Nor is it a valid literal expression.

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

Practical How-To

list files

list dirs

on dir

on file

Windows config

misc


PowerShell in Depth

Programing PowerShell

Value Types

String

Variable

Boolean

Conditional

Data Structure

Loop and Iteration

Input/Output

Function

Profile and Script

Script Examples