Chapter 4. Operators and expressions
This chapter covers:
Operators, Mr. Rico! Millions of them!
Robert A. Heinlein, Starship Troopers (paraphrased)
So far, we’ve covered the basics, and we’ve covered the type system in considerable depth. Now let’s look at how you can combine all this stuff and get some real work done. As in any language, objects are combined with operators to produce expressions. When these expressions are evaluated, the operators perform their operations on objects, giving you (hopefully) useful results. This chapter covers the set of basic operators in PowerShell and how they’re used in expressions. The operators we’re going to cover in this chapter are shown in figure 4.1.
As you can see, PowerShell has operators. Lots of operators—the full complement you’d expect in a conventional programming language and several more. In addition, PowerShell operators are typically more powerful than the corresponding operators in conventional languages such as C or C++. So, if you invest the time to learn what the PowerShell operators are and how they work, in a single line of code you’ll be able to accomplish tasks that would normally take a significant amount of programming.