In basic terms, when you pipeline commands in PowerShell, you are sending the results from one command to another command by using the pipeline character "
|" (which is technically ASCII character 124). This allows for creating complex "pipelines" of commands that daisy-chains from one command to another. Visually, it looks like this:
Command 1 | Command 2 | Command 3 | Command 4 ...
Notice that we used the word "Command" and not "cmdlet". This is because a cmdlet in PowerShell is just a portion of the overall commands available. A pipeline could contain not only a cmdlet, but also any other command used within PowerShell that would accept pipeline input, or any command that would provide input to another command, such as an array.
As an example, we will do a simple pipeline that send the output from the Get-Process cmdlet for an application that is running, such as word.exe, to the Stop-Process cmdlet so the application is terminated. This is also an example of a cmdlet to cmdlet pipeline.
Get-Process -Name word.exe | Stop-Process
An example of using a pipeline to send output from a PowerShell
dir command to the PowerShell
measure-object command is shown below.
dir c:\scripts\*.ps1 -Recurse | measure-object -Property length –sum
You can read more about PowerShell pipelines in this Microsoft documentation.