L2. The Pipeline: Objects, Properties, and Methods
Learn how PowerShell passes objects through the pipeline and how to inspect, select, sort, and format those objects without brittle text parsing.
The Mental Model
The pipeline is the center of PowerShell. A command writes objects. The next command receives those objects. You can inspect the object shape, select the properties you need, and pass the result onward.
Get-Process | Get-Member
Get-Process | Select-Object -First 5 Name, Id, CPU
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10
Get-Member is your microscope. If you do not know what a command returns, pipe it to Get-Member before guessing property names.
Select vs Format
Select-Object changes the objects in the pipeline. Format-Table and Format-List change how output looks on screen. For scripts, export, or downstream processing, select data first and format only at the end.
| Goal | Command |
|---|---|
| Keep specific properties | Select-Object Name, Status |
| Sort by a property | Sort-Object StartTime |
| Group by a property | Group-Object Status |
| Display in columns | Format-Table |
| Display all properties vertically | Format-List * |
Practical Example
Get-Service |
Where-Object Status -eq 'Running' |
Sort-Object DisplayName |
Select-Object Name, DisplayName, StatusThis reads like a sentence: get services, keep running ones, sort by display name, and return only the fields we care about.
Lab
- Use
Get-Process | Get-Memberto find the process object type. - List the 10 processes using the most CPU.
- List stopped services with only
Name,DisplayName, andStatus. - Explain why
Format-Tableshould usually be the last command in a pipeline.
Sources
- Microsoft Learn: PowerShell 101 introduction
- ✓Use Get-Member to inspect the type, properties, and methods returned by a command
- ✓Select-Object shapes pipeline data; Format-* commands are for final display
- ✓Where-Object filters objects by property values
- ✓Sort-Object orders objects without converting them to text
- ✓Object pipelines are less fragile than parsing column-aligned command output
1. Which command should you use to discover the properties available on pipeline objects?
2. Why should Format-Table usually appear at the end of a pipeline?
Recommended: Pluralsight
This free course covers the theory. Pluralsight adds structured video courses, hands-on Azure labs, and timed practice exams to make it stick before exam day.