~2 min read • Updated Dec 21, 2025
1. Logical and Comparison Operators
- -eq / -ne: Equal to / Not equal to.
- -gt / -lt / -ge / -le: Greater than, Less than, Greater or equal, Less or equal.
- -like / -notlike: Wildcard string comparison.
- -contains / -notcontains: Checks if a collection contains an element.
- -in / -notin: Tests if a value exists in an array.
Comparisons are case-insensitive by default, but case-sensitive versions exist (e.g., -ceq).
2. Boolean Operators
- -and: True if all subexpressions are True.
- -or: True if any subexpression is True.
- -not / !: Negates the result.
- -xor: True if only one subexpression is True.
3. Bitwise Operators
- -band: Returns 1 if both bits are 1.
- -bor: Returns 1 if either bit is 1.
- -bxor: Returns 1 if only one bit is 1.
Useful for working with bitmasks, such as user account flags in directory services.
4. Arithmetic Operators
- +: Addition or string concatenation.
- -: Subtraction.
- *: Multiplication (numeric or string repetition).
- /: Division.
- %: Modulo (remainder).
- ++ / --: Increment / Decrement.
- += / -= / *= / /=: Shortcut operations.
5. String and Array Operators
- -replace: Replace substrings.
- -split: Split strings into arrays.
- -join: Join array elements into a string.
6. Type Operators
- -is: Tests object type.
- -isnot: Tests if object is not of a type.
- -as: Converts object type.
Supports KB, MB, GB, TB, PB units for byte calculations.
7. Format Operator
The -f operator creates formatted strings with placeholders. Example:
"Today is {0:d} and Pi is {1:N}" -f (Get-Date), [math]::pi8. Miscellaneous Operators
- & (Call Operator): Executes a string or script block.
- $() (Subexpression): Executes expressions inside double quotes.
Conclusion
PowerShell operators form the backbone of scripting logic and data manipulation. By mastering comparison, arithmetic, type, and special operators, administrators can build powerful, efficient scripts for system management.
Written & researched by Dr. Shahin Siami