0
0
PowerShellscripting~10 mins

Pipeline concept (|) in PowerShell - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Pipeline concept (|)
Command 1 executes
Output objects from Command 1
Pipeline operator | passes objects
Command 2 receives objects as input
Command 2 processes and outputs result
Display final output
The pipeline sends output objects from one command directly as input to the next command, chaining commands smoothly.
Execution Sample
PowerShell
Get-Process | Where-Object {$_.CPU -gt 100} | Select-Object -Property Id, ProcessName
This command gets all processes, filters those using more than 100 CPU units, then selects and shows their Id and ProcessName.
Execution Table
StepCommandInputActionOutput
1Get-ProcessNoneRetrieve all running processesList of process objects
2Where-Object {$_.CPU -gt 100}List of process objectsFilter processes with CPU > 100Filtered list of process objects
3Select-Object -Property Id, ProcessNameFiltered list of process objectsSelect only Id and ProcessName propertiesList of objects with Id and ProcessName
4OutputList of objects with Id and ProcessNameDisplay on screenTable of Id and ProcessName
💡 Pipeline ends after Select-Object outputs the final filtered and selected process list.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final Output
ProcessesNoneAll running processesProcesses with CPU > 100Processes with only Id and ProcessNameDisplayed table of Id and ProcessName
Key Moments - 3 Insights
Why does the output of Get-Process go directly into Where-Object without storing in a variable?
Because the pipeline operator (|) passes the output objects directly from Get-Process to Where-Object, so no need to store them separately. See execution_table steps 1 and 2.
What type of data is passed through the pipeline between commands?
PowerShell passes objects, not just text, so each command receives full objects to work with. This is shown in execution_table where process objects flow through steps.
Can the pipeline have more than two commands chained?
Yes, as shown in the example, three commands are chained with two pipeline operators, passing data step-by-step until final output.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the output of Step 2?
AFiltered list of process objects with CPU > 100
BAll running processes
CList of objects with only Id and ProcessName
DDisplayed table of Id and ProcessName
💡 Hint
Check the 'Output' column in row for Step 2 in execution_table.
At which step does the pipeline select only specific properties of the processes?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look at the 'Command' and 'Action' columns in execution_table for Step 3.
If we remove the pipeline operator between Get-Process and Where-Object, what happens?
AWhere-Object receives no input and returns nothing
BCommands run sequentially but not connected
CGet-Process output is stored automatically
DThe script throws a syntax error
💡 Hint
Think about how pipeline operator connects commands as shown in concept_flow.
Concept Snapshot
PowerShell pipeline (|) passes output objects from one command as input to the next.
Commands chain smoothly: Command1 | Command2 | Command3.
Objects flow, not just text, enabling powerful filtering and selection.
No need for temporary variables between commands.
Final output displays after last command processes data.
Full Transcript
The PowerShell pipeline operator (|) connects commands by passing output objects from one command directly as input to the next. For example, Get-Process retrieves all running processes and sends them through the pipeline to Where-Object, which filters processes using more than 100 CPU units. Then Select-Object picks only the Id and ProcessName properties to display. This chaining avoids storing intermediate results in variables. Each step processes objects, not just text, enabling powerful and efficient scripting. The pipeline ends after the last command outputs the final result to the screen.