Key Takeaways
- The pipe character
|connects commands so one stage can provide objects to the next. Where-Object,Sort-Object, andSelect-Objectwork with object properties rather than with the terminal’s displayed columns.$_and$PSItemmean “the current pipeline object” inside a script block.- Pipeline input works only when a receiving cmdlet has a compatible parameter that accepts it.
- Format output last; use
Get-MemberandGet-Helpbefore guessing what a pipeline carries.
OSPowerShell.001 introduced cmdlets and help, while OSPowerShell.002 established that PowerShell commands commonly return structured objects. This lesson connects those ideas: a PowerShell pipeline moves those objects through a sequence of cmdlets so each stage can filter, sort, select, or act on meaningful data.
Elementary Overview
Imagine a conveyor belt in a workshop. Each item arrives at one station, is checked or changed, then continues to the next station. In PowerShell, the conveyor belt is the pipe character |. A command can place service, process, file, or other objects on the belt; later commands can inspect their named properties instead of trying to read a table as if it were plain text.
That distinction matters because the table on a terminal is only a view. PowerShell cmdlets usually send objects through a pipeline, while a native program’s standard output normally enters PowerShell as text strings. Start with Get-Member whenever you need to see what a cmdlet really produced.
A Pipeline Is Object Flow
This read-only pipeline starts with services, keeps only running services, sorts them by display name, and selects a small set of useful properties. Each line ending in | continues the same pipeline on the next line.
Get-Service |
Where-Object { $_.Status -eq 'Running' } |
Sort-Object -Property DisplayName |
Select-Object -First 10 Name, Status, DisplayName
Get-Service produces service objects. Where-Object tests each object’s Status property, Sort-Object uses DisplayName, and Select-Object creates the final focused output. The names are not arbitrary: inspect the incoming objects with Get-Service | Get-Member if a property is unfamiliar.

Filter, Sort, Select, Then Format
Keep formatting at the end of a working pipeline. Format-Table makes an easy-to-read terminal display, but it changes the output into formatting information that is not suitable for later data tasks such as Export-Csv. Build the objects first and display them last.
Get-Service |
Where-Object { $_.Status -eq 'Running' } |
Sort-Object -Property DisplayName |
Select-Object -First 10 Name, Status, DisplayName |
Format-Table -AutoSize
The same approach supports Windows process troubleshooting. First select the facts you need—such as a process name and PID—then use the final stage for the report, export, or carefully reviewed action. Sorting is a useful reminder that not every stage streams immediately: it must see the full input set before it can produce a complete sorted result.
The Current Object Inside a Filter
Inside a script block, $_ and $PSItem are two names for the current object arriving at that point in the pipeline. This example lists PowerShell processes without changing anything on the computer.
Get-Process |
Where-Object { $_.ProcessName -like 'pwsh*' } |
Select-Object ProcessName, Id
The filter is evaluating the ProcessName property of one process object at a time. If you want to filter a different kind of object, inspect it first rather than assuming it carries the same properties. That habit keeps one-liners readable and reduces brittle scripts.
Pipeline Binding Is a Contract
A pipe does not make every pair of commands compatible. The receiving cmdlet must expose a parameter that accepts pipeline input, and PowerShell must be able to bind the incoming object to it. Microsoft documents two common patterns: ByValue, based on a compatible type, and ByPropertyName, based on an incoming property whose name matches a parameter or alias.
# Preview only. -WhatIf prevents a service from being stopped.
Get-Service -Name w32time -ErrorAction SilentlyContinue |
Stop-Service -WhatIf
If the Windows Time service exists, Get-Service sends a service object and Stop-Service can accept it by value through its input-object parameter. -WhatIf reports the action it would take without making the change, which is a good habit when learning an administrative pipeline.
# ByPropertyName: the incoming object has a Name property.
[pscustomobject]@{ Name = 'w32time' } |
Stop-Service -WhatIf
The second example depends on a matching Name property. Confirm behavior with Get-Help Stop-Service -Parameter InputObject and Get-Help Stop-Service -Parameter Name; the help output states whether a parameter accepts pipeline input and whether it is by value, property name, or both.
Troubleshoot a Broken Pipeline
- Run the first command by itself and inspect its type with
Get-Member. - Read the receiving command’s parameter help instead of assuming it accepts pipeline input.
- Keep the pipeline read-only while you test it; add
-WhatIfwhere a cmdlet supports it. - Check permissions and error messages before changing the command or its data.
- Place formatting commands at the endpoint, after filtering and selection.
These checks matter in systems work because a pipeline may cross process, service, file, or remote-management boundaries. Clear stages make the workflow easier to audit, particularly before a command changes state.
Practice
- Run the service pipeline and replace
'Running'with'Stopped'. - Use
Get-Process | Get-Memberto find properties available on a process object. - Create a pipeline that lists the first five process names and IDs in alphabetical order.
- Run
Get-Help Stop-Service -Parameter InputObjectand identify the line that describes pipeline input. - Run either
Stop-Serviceexample only with-WhatIfand read the preview carefully.
Knowledge Check
- What travels through a typical PowerShell cmdlet pipeline?
- What does
$_represent insideWhere-Object { }? - Why should
Format-Tablenormally be the final stage? - What is the difference between pipeline input by value and by property name?
- Which two commands help you inspect an object and a parameter’s pipeline support?
Answers
- Structured objects, not merely the text shown in the terminal.
- The current object being evaluated at that stage.
- It creates display-oriented formatting data instead of preserving practical objects for later data work.
- By value uses a compatible object type; by property name uses a matching property or alias on the incoming object.
Get-MemberandGet-Help <cmdlet> -Parameter <name>.
Sources and Further Reading
- Microsoft Learn: One-liners and the pipeline
- Microsoft Learn: about_Pipelines
- Microsoft Learn: about_Parameter_Binding
Elementary Conclusion
A PowerShell pipeline is a way to pass organized pieces of information from one command to the next. Learn what each command produces, choose one clear job for every stage, and preview any action command before it runs. That turns a long command line into a readable, testable workflow instead of a fragile string of symbols.
BitcoinVersus.Tech Editor’s Note:
We volunteer daily to ensure the credibility of the information on this platform is Verifiably True. If you would like to support to help further secure the integrity of our research initiatives, please donate using the QR code provided

For best QR-code scanning results, please scan this donation code from a desktop or larger screen. Mobile screens may prevent camera recognition.

Leave a Reply