Chapter 4. Review: parameter binding and the PowerShell pipeline

 

Take traditional pipeline behavior from shells like Bash and Cmd.exe. Mix in Power-Shell’s unique object-oriented nature. Add a dash of Linux-style command parsing. The result? PowerShell’s pipeline, a fairly complex and deeply powerful tool for composing tools into administrative solutions. To be a toolmaker is to understand the pipeline at its most basic level, and to create tools that take full advantage of the pipeline. Although we covered these concepts in Learn Windows PowerShell in a Month of Lunches, in this chapter we’ll go deeper and focus on the pipeline as something to write for, rather than to just use.

4.1. Visualizing the pipeline

Grab a sheet of paper and a pen. Draw yourself something like figure 4.1. Now, write some command names in those boxes. Maybe Get-Process in the first box, maybe ConvertTo-HTML in the second box, and perhaps Out-File in the third box. Use pencil, if you have one, so you can erase those and repeat the exercise with other commands in the future.

Figure 4.1. Visualizing the pipeline
Try it Now

Go on—actually draw the boxes. We could have just repeated the finished figure here in the book, and believe us, our editor wanted us to, but there’s value in you doing this physical thing for yourself.

4.2. It’s all in the parameters

4.3. Plan A: ByValue

4.4. ByPropertyName

4.5. Summary