0
0
PowerShellscripting~5 mins

Pipeline object flow in PowerShell

Choose your learning style9 modes available
Introduction
The pipeline lets you send data from one command to another easily, like passing a ball between friends.
You want to list files and then filter only certain types.
You need to get processes and sort them by memory use.
You want to find services that are running and display their names.
You want to take output from one command and use it as input for another without saving to a file.
Syntax
PowerShell
command1 | command2 | command3
The pipe symbol | sends output from one command as input to the next.
Each command works on objects, not just text, making it powerful and flexible.
Examples
Gets all running processes and sorts them by CPU usage from highest to lowest.
PowerShell
Get-Process | Sort-Object CPU -Descending
Lists all files and filters only those with the .txt extension.
PowerShell
Get-ChildItem | Where-Object { $_.Extension -eq ".txt" }
Finds all running services and shows their names and status.
PowerShell
Get-Service | Where-Object { $_.Status -eq "Running" } | Select-Object Name, Status
Sample Program
This script lists files in the current folder that are larger than 1000 bytes and shows their names and sizes.
PowerShell
Get-ChildItem | Where-Object { $_.Length -gt 1000 } | Select-Object Name, Length
OutputSuccess
Important Notes
The pipeline passes objects, so you can access properties like $_.Name or $_.Length inside commands.
Use curly braces { } to write conditions or scripts inside the pipeline.
You can chain many commands with | to build complex tasks step-by-step.
Summary
The pipeline uses | to send data from one command to another.
It works with objects, making filtering and sorting easy.
You can combine commands to do powerful tasks without extra files.