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.

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

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.

4.1. Operators for working with types

4.2. Unary operators

4.3. Grouping and subexpressions

4.4. Array operators

4.5. Property and method operators

4.6. Format operator

4.7. Redirection and redirection operators

4.8. Working with variables

4.9. Summary

sitemap