Comparison Operators
The PowerShell comparison operators allow you to compare
expressions against each other. By default, PowerShell’s comparison
operators are case insensitive. For all operators where case sensitivity
applies, the –i prefix makes this
case insensitivity explicit, while the –c prefix performs a case-sensitive
comparison.
Windows PowerShell comparison operators | |
|---|---|
Operator | Meaning |
| The equality operator: $leftValue –eq $rightValue For all primitive
types, returns When used with arrays, returns all elements
in When used with any other type, PowerShell uses that type’s
|
| The negated equality operator: $leftValue –ne $rightValue For all primitive
types, returns When used with arrays, returns all elements
in When used with any other type, PowerShell returns the
negation of that type’s |
| The greater-than-or-equal operator: $leftValue –ge $rightValue For all primitive
types, returns When used with arrays, returns all elements in When used with any other type, PowerShell returns the
result of that object’s |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access