10 The pipeline, deeper

 

At this point, you’ve learned to be pretty effective with PowerShell’s pipeline. Running commands (e.g., Get-Process | Sort-Object VM -desc | ConvertTo-Html | Out-File procs.html) is powerful, accomplishing in one line what used to take several lines of script. But you can do even better. In this chapter, we dig deeper into the pipeline and uncover some of its most powerful capabilities, which allow you to pass data between commands the right way with less work.

10.1 The pipeline: Enabling power with less typing

One of the reasons we like PowerShell so much is that it enables us to be more effective administrators without having to write complex scripts, as we used to have to do in Bash. The key to powerful one-line commands lies in the way the PowerShell pipeline works.

Let us be clear: you could skip this chapter and still be effective with PowerShell, but in most cases you’d have to resort to Bash-style scripts and programs. Although PowerShell’s pipeline capabilities can be complicated, they’re probably easier to learn than more-complicated programming skills. By learning to manipulate the pipeline, you can be much more effective without needing to write scripts.

The whole idea here is to get the shell to do more of your work for you, with as little typing as possible. We think you’ll be surprised at how well the shell can do that!

10.2 How PowerShell passes data down the pipeline

10.3 Plan A: Pipeline input ByValue

10.4 Plan B: Pipeline input ByPropertyName

10.5 When things don’t line up: Custom properties

10.6 Working with Azure PowerShell

10.7 Parenthetical commands

10.8 Extracting the value from a single property

10.9 Lab

10.10 Lab answers

10.11 Further exploration