Chapter 13. Using all the pipelines

 

A couple of chapters ago, we pointed out that adding [CmdletBinding()] to a Param() block would enable the output of certain commands for verbose, warning, informational, and other output. Well, it’s time to put that to use and demonstrate why you’d want to use them.

13.1. Knowing the six channels

It’s useful to understand that PowerShell has six channels, or pipelines, rather than the one we normally think of. First up is the Success pipeline, which is the one you’re used to thinking of as “the pipeline.” This gets some special treatment from the PowerShell engine. For example, it’s the pipeline used to pass objects from command to command. Additionally, at the end of the pipeline, PowerShell sort of invisibly adds the Out-Default cmdlet, which has the effect of running any objects in the pipeline through PowerShell’s formatting system. Whatever hosting application you’re using—the PowerShell console, ISE, and so on—is responsible for dealing with that output by placing it onto the screen or doing something else with it.

But there are five other pipelines:

  1. Success, which we discussed
  2. Error
  3. Warning
  4. Verbose
  5. Debug
  6. Information

Those numbers correspond with how PowerShell references each pipeline for redirection purposes.

13.2. Adding verbose and warning output

13.3. Doing more with -Verbose

13.4. Information output

13.5. Your turn