Written
June 12, 2017
Hi, I have not seen this myself. But if servers have a lot of processes running I can see this script taking a long time to run.
I did some measuring of what parts of the script was taking the most time, and unfortunately to tackle this I will have to rewrite everything from scratch (removing all the original code). In my environment the script normally runs for about 30 - 40 sec.
To find out more about you environment specifics take the script and run it on the server where you are seeing the problem. Run it from powershell command line (admin) and not from the ISE.
Do :
.\SCOMpercentageCPUTimeCounter.ps1 -ComputerName "servername.mydomain.dom" -ConfigForRun "False" -ProcessIterationCount 3
Usually it is the iteration count that makes this script take a long time to complete. It uses this to get several rounds of performance data from the processes the health service spawns. This is then averaged. One way of reducing runtime is to set a lower number for ProcessIterationCount. Another is to set the original script timeout value back to 300 sec, instead of the 120 I have set.