5

Operators

In programming, an operator is a keyword that is used to manipulate an item of data. An operator might be used to compare values, add or subtract, perform replacements, split or join values, and so on. An operator is a fundamental part of any programming language, and PowerShell is no exception.

PowerShell has a wide variety of operators; each is explored within this chapter.

Many of the operators in PowerShell are binary, requiring two arguments (operands), such as -eq, -like, and so on.

Unary operators require a single argument (on the right-hand side), such as the -not and -bnot operators.

Ternary operators, which are new in PowerShell 7, require three arguments.

A small number of operators can be used as both unary and binary, ...

Get Mastering PowerShell Scripting - Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.