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 |
Get Windows PowerShell Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.