How can I write a PowerShell program that will Average CPU consumption over the time range of 15 minutes?
Below is my sample command
Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average | Select Average | Out-File c:\RM.txt -Encoding utf8
PowerShell program that will Average CPU consumption over the time range of 15 minutes
this gives you 60 values of per-10 seconds CPU time average:
GET-COUNTER -Counter "\Prozessor(_Total)\Prozessorzeit (%)" -SampleInterval 10 -MaxSamples 60 |select -ExpandProperty countersamples | select -ExpandProperty cookedvalue
then you can proceed with measure-object
to gather the average.
the performance counter will be named according to your OS language settings: english: "\Processor(_Total)\% Processor Time"
be aware that ticket generation depending on CPU usage is usually always provided by system management agents on servers especially in cloud environments.