Forum Discussion
Getting CPU Utilization through PS script
Hello Folks,
I'm working on creating a PS script for basic server health check and planning on automating it to execute and send the health check report through email. I'm stuck with getting the correct CPU Utilization status of the server. I'm planning on implementing one of the below two methods:
1. To get the average CPU utilization within a span of 180 seconds using the following:-
$cpuUtil = (get-counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 1 -MaxSamples 180 | select -ExpandProperty countersamples | select -ExpandProperty cookedvalue | Measure-Object -Average).average
2. To get the CPU Utilization individually for each second for 180 seconds (180 readings) and count the occurrences where the utilization was greater than say 90%. If the number of occurrences are more than, say 170 then flag as high CPU utilization.
Which of the above 2 methods would be most appropriate one?
Thanks in advance.
1 Reply
- navinyaCopper Contributor