Where-Object is heart of filtering results generated by Get-* commands in Powershell. One of the parameters that Where-Object takes is FilterScript where you can specify the comparison conditions for a given object. This parameters evaluates to true or false depending on comparison result. For example you may want to filter result based on some preoprty or value being less than or greater than certain value. First reaction you will have is to say that you can use operator like < or >. Well, that does not work in FilterScript. Following is list of comparison operators that are used in Powershell scripting.
| Operator |
Meaning |
| -eq |
is equal to |
| -ne |
Is not equal to |
| -lt |
Is less than |
| -le |
Is less than or equal to |
| -gt |
Is greater than |
| -ge |
Is greater than or equal to |
| -like |
Is like (wildcard comparison for text) |
| -notlike |
Is not like (wildcard comparison for text) |
| -contains |
Contains |
| -notcontains |
Does not contain |
When you are using comparison operator for text comparison, the operators are case-insensitive by default.