Chapter 7. The pipeline, deeper
So far, you’ve learned to be pretty effective with PowerShell’s pipeline. Running commands like Get-Process | Sort VM -desc | ConvertTo-HTML | Out-File procs.html is pretty powerful, accomplishing in one line what used to take several lines of script. But you can do even better! In this chapter, we’ll dig deeper into the pipeline and uncover some of its most powerful capabilities.
One of the reasons I like PowerShell so much is that it enables me to be a more effective administrator without having to write complex scripts, like I used to have to do in VBScript. But the key to powerful one-line commands lies in the way the PowerShell pipeline works.
Let me be clear: you could skip this chapter and still be effective with PowerShell, but you would in most cases have to resort to VBScript-style scripts and programs. Although PowerShell’s pipeline capabilities can be complicated, they’re probably easier to learn than more-complicated programming skills, and by learning to really 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. I think you’ll be surprised at how well the shell can do that!
Let’s start by looking at a command that you’ve seen earlier in this book: