Get CPU Load

by Mar 8, 2013

To get the average total CPU load for your local system or a remote system, use Get-Counter. The example below returns the average total CPU load for a 10 second interval:

PS> (Get-Counter '\processor(_total)\% processor time' -SampleInterval 10).CounterSamples.CookedValue

Unfortunately, the name of the performance counter is a localized (!) value, so it is translated into the language of your culture, and unless you are running an English copy of Windows, you'd have to look up the localized name. To dump the names of all performance counters, use this line:

PS> Get-Counter -ListSet * | Select-Object -ExpandProperty Counter

To query a remote system, prepend the computer name. This will get the CPU load from a server called 'storage1':

PS> (Get-Counter '\\storage1\processor(_total)\% processor time' -SampleInterval 10).CounterSamples.CookedValue

Twitter This Tip! ReTweet this Tip!