Hi I'm working on a script to take samples of the processor over a period of time right now I'm using just 5 seconds to run it quickly for testing... I'm not to familiar with powershell but found a few things between this site and others to come up with this, which works on my Windows 7 machine but not on windows 2008 R2, once I get the average I'll be placing it in an if statement to send an alert if the processor becomes to bogged down. I'd appreciate any help with this matter and thanks ahead of time....
$a=Get-counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 1 -MaxSamples 5
($a.CounterSamples.CookedValue | Measure-Object -Average).average