Reputation: 513
I have a script that outputs my overall cpu usage. But if I compare this to the Task Manager, I get a different number. Is my script just wrong or is there a better way to do it?
$cpu = Get-WmiObject win32_processor
logwrite $cpu.LoadPercentage
Task Manager says 26% while the output file says 1%. My script says 0%, 1% or 2% most of of the time.
Upvotes: 0
Views: 5062
Reputation: 3350
The reason being, CPU Usage
fluctuates with each passing moment, and that is reflected in your task manager. If you see your task manager the CPU usage
will be fluctuating every time.
$cpu.LoadPercentage
from your script gives you the CPU usage
at the time of creation
of your output file. Hence, you see the anomalies. You should be looking for a more dynamic way of getting CPU usage
or getting it in intervals.
Upvotes: 3