<tr>
<th colspan="2">Numeric</th>
</tr>
<tr>
<td>Is equal</td>
<td><code>if ($VAR1 -eq $VAR2)</code></td>
</tr>
<tr>
<td>Not equal</td>
<td><code>if ($VAR1 -ne $VAR2)</code></td>
</tr>
<tr>
<td>Less than</td>
<td><code>if ($VAR1 -lt $VAR2)</code></td>
</tr>
<tr>
<td>Less than or equal</td>
<td><code>if ($VAR1 -le $VAR2)</code></td>
</tr>
<tr>
<td>Greater than</td>
<td><code>if ($VAR1 -gt $VAR2)</code></td>
</tr>
<tr>
<td>Greater than or equal</td>
<td><code>if ($VAR1 -ge $VAR2)</code></td>
</tr>
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") |
- * By default all PowerShell all comparison operators are case-insensitive. Prefixing with
i
makes this explicit. - ** Regular expression matches will be available in
$matches[]
.
- about_Comparison_Operators: https://technet.microsoft.com/en-us/library/hh847759.aspx