I am thinking to produce a daily report of vms with hung process - vms with an average of cpu utilization 80%+ over the last 4 fours is a sign and needs to be look up.
This script will kick off everyday at 5am and sweep 500+ vms, is there anything else I should put in the consideration?
$vm = "abcd"
$statcpu = Get-Stat -Entity $vm -Stat cpu.usage.average -Start (Get-Date).AddHours(-4) -Finish (Get-Date).AddHours(-0)
$Avgcpu = $statcpu | where {$_.Value -ne 0} | Measure-Object -Property value -Average -Maximum | select Average
if ($Avgcpu.Average -gt 80) {write-host $vm}