Understanding PowerShell Operators

Now that we are starting to look at more complex logic statements, our variables need to be evaluated somehow. In this tutorial, you will learn of the various operators in PowerShell.


If you have not already done so, click open Windows PowerShell ISE.

The Concept…

There are different forms of operator: Comparison and Logical. Comparison operators take two variables or objects and compare them. The comparison operators are listed in the chart below:




Equal to


Less than


Greater than


Greater than or Equal to


Less than or equal to


Not Equal to


Returns TRUE if value is a certain data type


Returns TRUE if the value is not a certain data type


Like (uses Wildcard for pattern matching)


Not like (uses wildcard for pattern searching)


A match using regular expressions


Used to see whether a collection or group of items contains a given term.


Used to see whether a collection or group of items does not contain a given item.

Logical operators say what variables are or are not equal to. Or if they can be either or. We may want variable $i to equal or not to equal something in a conditional loop. For example, while variable $i = 3 –or 9 –or 1, print out to the system, "You have a factor of nine!". The example in reality could use quite a bit of logic before it actually works accurately, but that is an example of how the logical operators would work. The logical operators are listed in the chart below.











Remarks last but not least…

This was merely a small glimpse on what operators are available in PowerShell. These operators will be used quite frequently throughout the tutorials on the site. Join us next time for additional Windows PowerShell tutorials! Till then…