Chapter 19. Troubleshooting pipeline input
Part of what makes PowerShell so unique and powerful is its object-oriented pipeline. When you’re writing tools, it’s especially important that you understand how the pipeline works, how your tools can work within it and—most important of all—that you know how to troubleshoot what’s happening in the pipeline. That’s what this chapter will cover.
Whenever you pipe one command to another—say, Get-Service | Where Status –eq 'Running' | Sort Name | Export-CSV services.csv—output is taken from one command and passed to the next. There’s no magic way for that output to be passed along: PowerShell commands can accept input only via their parameters. In this example, PowerShell has to take the output of Get-Service and figure out which parameter of Where-Object can accept those objects. After Where-Object runs, its output goes into the pipeline, and PowerShell has to figure out which parameter of Sort-Object can accept that. This process of figuring out is called pipeline parameter binding.