0

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.

Community
  • 1
  • 1
Harsh Jaswal
  • 447
  • 3
  • 14

1 Answers1

0

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
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206