How to record the load on CPU for a particular time period?

1.4k Views Asked by At

I am trying to record the load on the CPU for certain time period using PowerShell. Is there any way to record the CPU utilization in the task manager? I have tried this: Tracking CPU and Memory usage per process. But it didn't work.

1

There are 1 best solutions below

2
On

Use the Get-Counter cmdlet with the SampleInterval parameter:

$interval = 20 #seconds
$counterSample = Get-Counter '\Processor(_Total)\% Processor Time' -SampleInterval $interval
$avgLoad = $counterSample.CounterSamples.CookedValue