Chapter 4. Operators and expressions

 

This chapter covers:

  • 4.1 Arithmetic operators
  • 4.2 The assignment operators
  • 4.3 Comparison operators
  • 4.4 Pattern matching and text manipulation
  • 4.5 Logical and bitwise operators
  • 4.6 Summary

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.

Figure 4.1. The broad groups of operators we’ll cover in this chapter

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.

4.1. Arithmetic Operators

 
 

4.2. The Assignment Operators

 
 
 

4.3. Comparison Operators

 
 

4.4. Pattern Matching and Text Manipulation

 
 

4.5. Logical and Bitwise Operators

 
 
 
 

4.6. Summary

 
 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest