Tech Blog‎ > ‎

Powershell - Get CPU Usage by Process (remote)

posted Apr 19, 2017, 1:24 PM by Victor Zakharov   [ updated Apr 19, 2017, 1:25 PM ]
You would expect Get-Process to do the job, but it turns out that its CPU metric is not on a 0..100% scale.

Here is a one-liner (find who's eating into your CPU - or that of a remote server):

gwmi Win32_PerfFormattedData_PerfProc_Process -filter "Name <> '_Total' and Name <> 'Idle'" -Computer $servername | where { $_.PercentProcessorTime -gt 0 } | select Name, PercentProcessorTime

For some reason, the total percentage of all selected processes can be greater than 100, I'm guessing there was a measurement lag.
Don't forget to initialize $servername (or hard code it before executing).

Credit goes here.