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