powershell equivalent of linux 'ps -aux | sort -k3n'
I’m not entirely sure how I managed to not find out about Win32_PerfFormattedData_PerfProc_Process before now. I think the ‘sort -k3n’ does a sort by CPU-usage, but I’m sure there’s a better way of doing it than that.
gwmi Win32_PerfFormattedData_PerfProc_Process -ComputerName $ComputerName |
Sort-Object -Property PercentProcessorTime -desc |
select idprocess, name, IODataBytesPersec, PercentPrivilegedTime,PercentProcessorTime, PercentUserTime, workingset |
Select-Object -first 11 |
ft -AutoSize
gives:
idprocess name IODataBytesPersec PercentPrivilegedTime PercentProcessorTime PercentUserTime workingset
--------- ---- ----------------- --------------------- -------------------- --------------- ----------
0 _Total 849620 100 100 18 5667786752
0 Idle 0 100 100 0 4096
5552 sqlservr 236135 0 18 18 3040718848
3680 TmListen 344690 6 6 0 10211328
10012 PccNTMon 7574 6 6 0 4706304
496 services 0 0 0 0 11198464
744 svchost#3 0 0 0 0 69857280
568 svchost#2 0 0 0 0 14368768
792 svchost#1 0 0 0 0 24203264
2132 svchost 0 0 0 0 5054464
5888 Ssms#1 0 0 0 0 190734336