PowerShell: Pipeline Commands
These commands are almost always used by piping some command's output to them.
Foreach
Foreach-Object
(alias%
,foreach
)-
do something for each object.
dir | ForEach-Object { $_.fullname}
Select
Select-Object
(aliasselect
)-
filter by object properties, or first few, or last few.
dir | select -first 5
Filter (where)
Where-Object
(alias?
,where
)-
filter by boolean test.
dir -recurse | where { $_.name.length -gt 40}
Select-String
(aliassls
)-
Filter string objects by string pattern.
Sort
Sort-Object
(aliassort
)-
Sort
Format Output
Format-List
(aliasfl
)-
Format object as list. Useful when PowerShell truncates file path.
dir -recurse | fl
Format-Table
(aliasft
)-
Format object as table.