PowerShell: Test Order (Greater, Lesser)

By Xah Lee. Date: .

💡 TIP: Operator names are case-insensitive.

For all these operators, if left-hand-side is a collection, it filter the collection.

value1 -gt value2

return $true if value1 is greater than value2

4 -gt 3 # True

3 -gt 4 # False
collection -gt value

filter collection, return a array containing items that's greater than value

3,4,5,6,7 -gt 5
# 6, 7

(3,4,5,6,7 -gt 5).gettype().tostring() -ceq "System.Object[]"
# true
-ge

greater than or equal

-lt

less than

-le

less than or equal

-igt

case-insensitive -gt

-ige

case-insensitive -ge

-ilt

case-insensitive -lt

-ile

case-insensitive -le

-cgt

case-sensitive -gt

-cge

case-sensitive -ge

-clt

case-sensitive -lt

-cle

case-sensitive -le

PowerShell, Boolean Related