Chapter 8. The PowerShell pipeline

 

This chapter covers

  • Using PowerShell’s pipeline mechanism
  • Working with parameter binding
  • Troubleshooting the pipeline

Okay, we’ll admit it: We’re big PowerShell fans. You probably could have guessed that, but you might not know exactly why. It’s the pipeline. Although not everyone realizes it, PowerShell is incredibly different from other command-line shells in any other operating system, or even in older versions of Windows, and that difference is due primarily to the pipeline. It’s easy to use PowerShell without knowing much about the pipeline, but mastering PowerShell requires you to master the pipeline. That’s what this chapter will help you do.

8.1. How the pipeline works

We started using the pipeline almost from the very start of this book, and the previous chapter made heavy use of it. Heck, you’ve used it yourself if you’ve ever run a command like Dir | More, or Get-Service | Out-File, or Get-Process | Sort |Select, or any other combination of commands. That vertical bar, |, is the pipe character, and it indicates that you’re using PowerShell’s pipeline.

8.1.1. The old way of piping

In pretty much every other operating system shell we’re aware of, including Windows’ old Cmd.exe shell, you can pipe stuff from command to command. It’s worth understanding how older shells do it, so that you can better appreciate what Power-Shell’s up to.

8.2. Parameter binding ByValue

8.3. Pipeline binding ByPropertyName

8.4. Troubleshooting parameter binding

8.5. When parameter binding lets you down

8.6. The pipeline with external commands

8.7. Summary

sitemap