Colonel Panic Colonel Panic - 8 months ago 90
Powershell Question

Boolean literals in PowerShell

What are the boolean literals in PowerShell?


$true and $false.

Those are constants, though. There are no language-level literals for booleans.

Depending on where you need them, you can also use anything that coerces to a boolean value, if the type has to be boolean, e.g. in method calls that require boolean (and have no conflicting overload), or conditional statements. Most non-null objects are true, for example. null, empty strings, empty arrays and the number 0 are false.