Yes. These commands produce the same type of output: process Name, Id, and CPU, sorted by CPU in descending order.
Variation 1: Full cmdlet names
Get-Process |
Select-Object -Property Name, Id, CPU |
Sort-Object -Property CPU -Descending
Variation 2: Sort first, then select
Get-Process |
Sort-Object -Property CPU -Descending |
Select-Object -Property Name, Id, CPU
Variation 3: Use aliases
gps | select Name,Id,CPU | sort CPU -Descending
Variation 4: Show only top 10 highest CPU processes
Get-Process |
Sort-Object CPU -Descending |
Select-Object Name, Id, CPU -First 10
Best teaching version:
Get-Process |
Sort-Object -Property CPU -Descending |
Select-Object -Property Name, Id, CPU
Comment:
# This command gets all running processes, sorts them by CPU time from highest to lowest,
# and displays only the Name, Id, and CPU properties.
REF: AI Tools/ChatGPT
