Asked by:
get-counter Windows resource monitor

Question
-
I tried to create a script to check the same values I have in the Resource Monitor of Windows with Powershell. The process I try to find start by the word genetec.
I tried this option but the Cookvalue doesn't match with the results I have in the graphical interface
(Get-Counter '\Process(Genetec*)\% Processor Time').CounterSamples | Where-Object {$_.CookedValue -gt 5}
Do you know why the results are totally different. How does windows calculate CPU and CPU average in the graphical interface. Please, check the screenshot
you will notice the value goes between 24 and 25 but the powershell shows more than 98. what does this value mean?
thanks
Monday, January 8, 2018 7:39 PM
All replies
-
The two systems use different algorithms to produce the results. The GUI is a long time accumulated average The counter is a snapshot.
Taking an average over time will give a better match but it will never be exact.
\_(ツ)_/
Monday, January 8, 2018 7:49 PM -
Here is an example of how to get averages:
$samples = Get-Counter '\Process(Powershell)\% User Time' -SampleInterval 1 -MaxSamples 10 $samples.CounterSamples.Cookedvalue } | Measure-Object -Average
\_(ツ)_/
Monday, January 8, 2018 7:59 PM -
Generate and report a long term average.
Get-Counter '\Process(Powershell)\% User Time' -SampleInterval 1 -Continuous | ForEach-Object {$average=0;$count=0} { $count++ $average += $_.CounterSamples.Cookedvalue $average/$count }
\_(ツ)_/
- Proposed as answer by Albert LingMicrosoft contingent staff Monday, January 29, 2018 10:14 AM
Monday, January 8, 2018 8:06 PM