๐ง
Pipeline & Filtering
Select, sort, group, and aggregate objects in the pipeline.
Selecting and shaping
Pick specific properties
Keep only the columns you care about.
Get-Process | Select-Object Name, Id, CPUGet the top N items
Take the first few results.
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5Add a calculated property
Create a new column from an expression.
Get-Process | Select-Object Name,
@{ Name = "MemMB"; Expression = { [math]::Round($_.WorkingSet / 1MB, 1) } }Get unique values
Remove duplicates from a set.
Get-Process | Select-Object -ExpandProperty Company -UniqueSorting and grouping
Sort by a property
Order results ascending or descending.
Get-ChildItem | Sort-Object Length -DescendingGroup by a property
Bucket items and count each group.
Get-Process | Group-Object Company | Sort-Object Count -DescendingAggregating
Count, sum, and average
Compute statistics over a property.
Get-ChildItem -File | Measure-Object Length -Sum -Average -MaximumCount matching items
How many items pass a filter.
(Get-Service | Where-Object Status -eq 'Running').Count