Skip to content

Instantly share code, notes, and snippets.

@signalwarrant
Created March 9, 2021 18:42
Show Gist options
  • Save signalwarrant/0fdbcad68c567d49c5005e0dde1b97d3 to your computer and use it in GitHub Desktop.
Save signalwarrant/0fdbcad68c567d49c5005e0dde1b97d3 to your computer and use it in GitHub Desktop.
Sort-Select.ps1
# Selecting
#Default
Get-Process
# All Properties
Get-Process | Select-Object -Property * | Out-GridView
# Sorting
# Changes the default sorting order for Get-Process
Get-Process | Sort-Object CPU
# Minimize the data and sort
Get-Process | Select-Object ProcessName, CPU | Sort-Object CPU -Descending
## Caution
# Mission: Get the top 10 processes by CPU usage (which 10 processes have the most CPU usage)
Get-Process |
Select-Object ProcessName, CPU -First 10 |
Sort-Object CPU -Descending
# or
Get-Process |
Sort-Object CPU -Descending |
Select-Object ProcessName, CPU -First 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment