String | |
---|---|
Is equal (case insensitive) | if ($VAR1 -eq $VAR2) |
Is equal (case insensitive) * | if ($VAR1 -ieq $VAR2) |
Is equal (case sensitive) | if ($VAR1 -ceq $VAR2) |
Regular expression ** | if ($VAR1 -match "RegExp") |
Numeric | |
Is equal | if ($VAR1 -eq $VAR2) |
Not equal | if ($VAR1 -ne $VAR2) |
Less than | if ($VAR1 -lt $VAR2) |
Less than or equal | if ($VAR1 -le $VAR2) |
Greater than | if ($VAR1 -gt $VAR2) |
Greater than or equal | if ($VAR1 -ge $VAR2) |
Array | |
Contains | if (@("one") -ccontains "one") |
Not contains | if (@("one") -notcontains "one") |
- * By default all PowerShell all comparison operators are case-insensitive.
- Prefixing with
i
makes this explicit. - Prefixing with
c
makes this case-sensitive.
- Prefixing with
- ** Regular expression matches will be available in
$Matches[]
.
- about_Comparison_Operators: https://technet.microsoft.com/en-us/library/hh847759.aspx