Hi all
im new to powershell and i need help for a script that i need that will do the following:
when process reach high CPU kill it and start a service automatically. i created the following script with the example that the "notepad" is the process to kill and "fax" is the service to start immediately when the process "notepad" is killed. does the script correct?
$cpuutil=(get-counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 1 -MaxSamples 5 |
select -ExpandProperty countersamples | select -ExpandProperty cookedvalue | Measure-Object -Average).average
If ($cpuutil -ge 90)
{Get-Process notepad | Stop-Process -Force Start-Service fax}
Else
{Exit}