PowerShell for Windows Admins

Aug 31 2017   8:43AM GMT

PowerShell operators

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Powershell

PowerShell has operators – lots of operators. So many operators that it took us TWO chapters to work through them all in PowerShell in Action, third edition – https://www.manning.com/books/windows-powershell-in-action-third-edition. Here’s how you can discover the PowerShell operators.

PS> Get-Help about*operator*

Name
—-
about_Arithmetic_Operators
about_Assignment_Operators
about_Comparison_Operators
about_Logical_Operators
about_Operators
about_Operator_Precedence
about_Type_Operators

A quick listing gives us:

Arithmetic operators (+, -, *, /, %)

Assignment operators (=, +=, -=, *=, /=, %=)

Comparison operators (-eq, -ne, -gt, -lt, -le, -ge) (-match, -notmatch) (-like, -notlike)

(-in, -notin, -contains, -notcontains) (-bAND, -bOR, -bXOR, -bNOT)

Logical opertors (-and, -or, -xor, -not, !)

Redirection operators (>, >>, 2>, 2>, and 2>&1)

Type operators (-is, -isnot, -as)

And a bunch of special operators @(), & (call), [] (cast), comma, dot, –f , index opertor, pipeline operator, range operator, :: static member operator, $()

Also don’t forget –split, –join, –replace

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: