Chapter 4. Advanced operators and variables
This chapter covers
- Operators for working with types
- Unary operators
- Grouping and subexpressions
- Array, property, and method operators
- The format and redirection operators
- Working with variables
The greatest challenge to any thinker is stating the problem in a way that will allow a solution.
Bertrand Russell
The previous chapter covered the basic operators in PowerShell, and in this chapter, we’ll continue our discussion of operators by looking at the advanced ones, which include things that some people don’t think of as operators at all. We’ll break the operators into related groups, as shown in figure 4.1.
In this chapter, we’ll look at how to work with types, properties, and methods, and how to use these operators to build complex data structures. PowerShell is an automation engine for the Windows environment, and whatever you’re doing, you’ll need to manipulate data of some sort—for instance, Windows Management Instrumentation (WMI) query results, Active Directory user data, or data retrieved from a web service. Irrespective of the data source you’ll need the operators in this, and the previous chapter, to enable your processing of that data into the format you need to solve your problem.
The chapter concludes with a detailed discussion of how variables work in PowerShell and how you can use them with operators to accomplish significant tasks.