1

I found the command wmic cpu get LoadPercentage was recommended as a way to get a CPU load estimate from a command line.

It works as expected from a Windows 10 system:

c:\>wmic cpu get LoadPercentage
LoadPercentage
21

c:\>

From a Windows 2008r2 server, it doesn't return a value:

c:\>wmic cpu get LoadPercentage
LoadPercentage


c:\>

What can be done to allow this to work, or to get the data another way? I tried some of the other approaches in the referenced article and they didn't work either.

tim11g
  • 425
  • 5
  • 9
  • 21

1 Answers1

0

You can try with Powershell : How do I find the CPU and RAM usage using PowerShell?


Powershell :

Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average | Select Average

Batch :

@echo off
Title Get CPU load percentage
:Loop
cls
Powershell -C "Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average | Select Average"
Timeout /T 5 /NoBreak>nul
Goto Loop
Hackoo
  • 115
  • 5
  • The Powershell command you show does not work on Windows Server 2008r2. It runs but returns nothing. After some trial and error, I found this commmand works: `(Get-WmiObject Win32_Processor).LoadPercentage` From Windows CMD, I can run it as `powershell (Get-WmiObject Win32_Processor).LoadPercentage` It returns a single number, which appears to be the CPU Load Percentage. It is not exactly what Resource Monitor shows, but close enough. – tim11g Nov 24 '21 at 15:55