Sorry for my bad english, I hope you understand me..
I have a PowerShell script to monitor CPU usage and script executing well on PowerShell command line.
But when I schedule same script on Windows Task Scheduler, it start executing, but not respect parameters SampleInterval and MaxSamples. Like described on command below:
$Counter = @{
Counter = "\Processor(_Total)\% user time", "\Processor(_Total)\% idle time", "\Processor(_Total)\% Processor Time",
"\System\Processor Queue Length", "\System\Context Switches/sec", "\System\System Calls/sec"
SampleInterval = $intervalo
MaxSamples = $amostra
}
$metrics = Get-Counter @Counter
Copyright Notice:Content Author:「Leandro Brostolim」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/36649495/powershell-on-windows-task-scheduler