Changes

Basic Windows PowerShell 1.0 Operators

1,930 bytes added, 15:21, 26 November 2008
Windows PowerShell Comparison Operators
Windows PowerShell provides a range of comparison operators which can be used to compare one value with another. These operators work both with string and number based values assuming that you are comparing like with like (it is not meaningful, for example, to compare a string with numerical value). In terms of working with strings and characters, both case-sensitive and insensitive operators are supported.
 
<table border="1" cellspacing="0">
<tr style="background:#efefef;">
<th>Operator</th><th>Description</th>
<tr>
<td>-eq<td>Equal to (case insensitive)</td>
<tr>
<td>-ieq<td>Equal to (case insensitive)</td>
<tr>
<td>-ceq<td>Equal to (case sensitive)</td>
<tr>
<td>-ne<td>Not equal to (case insensitive)</td>
<tr>
<td>-ine<td>Not equal to (case insensitive)</td>
<tr>
<td>-cne<td>Not equal to (case sensitive)</td>
<tr>
<td>-gt<td>Greater than (case insensitive)</td>
<tr>
<td>-igt<td>Greater than (case insensitive)</td>
<tr>
<td>-cgt<td>Greater than (case sensitive)</td>
<tr>
<td>-ge<td>Greater than or equal to (case insensitive)</td>
<tr>
<td>-ige<td>Greater than or equal to (case insensitive)</td>
<tr>
<td>-cge<td>Greater than or equal to (case sensitive)</td>
<tr>
<td>-lt<td>Less than (case insensitive)</td>
<tr>
<td>-ilt<td>Less than (case insensitive)</td>
<tr>
<td>-clt<td>Less than (case sensitive)</td>
<tr>
<td>-le<td>Less than or equal to (case insensitive)</td>
<tr>
<td>-ile<td>Less than or equal to (case insensitive)</td>
<tr>
<td>-cle<td>Less than or equal to (case sensitive)</td>
<tr>
<td>-contains<td>Group of values in left hand operand contains value specified in right hand operand (case insensitive)</td>
<tr>
<td>-icontains<td>Group of values in left hand operand contains value specified in right hand operand (case insensitive)</td>
<tr>
<td>-ccontains<td>Group of values in left hand operand contains value specified in right hand operand (case sensitive)</td>
<tr>
<td>-notcontains<td>Group of values in left hand operand does not contain value specified in right hand operand (case insensitive)</td>
<tr>
<td>-inotcontains<td>Group of values in left hand operand does not contain value specified in right hand operand (case insensitive)</td>
<tr>
<td>-cnotcontains<td>Group of values in left hand operand does not contain value specified in right hand operand (case sensitive)</td>
<tr>
</table>