Reset monitor

This example shows how to reset the Windows Inventory Script monitor.

You first need to get the dot name of the monitor and the class the monitor targets. To get the class run this:

(get-scommonitor -name SCOM.Monitor.WindowsInventoryScript).target.Identifier.path

You also need to confirm the severity of the monitor or it won't work – sometimes alert severity does not match severity in health explorer.

Important: This can be slow. I am not sure it is the best way to reset monitors, but it works.

$Monitor="SCOM.Monitor.WindowsInventoryScript"
$Class="Microsoft.Windows.Computer"
$Severity="Warning" # Must match health state of the monitor (Success, Error, Warning)
$MonitorToReset = Get-SCOMMonitor -Name $Monitor
$Monitoringclass = Get-SCOMClass -Name $Class
$Monitoringclass | Get-SCOMClassInstance | where {$_.HealthState -eq $Severity} | foreach {$_.ResetMonitoringState($MonitorToReset) | select Status}

This is something I was messing around with when I had to reset health on all active alerts. It's a quick & dirty so it doesn't do any clever stuff like determine if it's a unit/aggregate/dependancy monitor. It just gets all active alerts and dumps the alert name, monitor dot name and monitor dot class name to a csv file (this is the info you need to run the above code). Then you clean up the csv by removing duplicates and doing text-to-columns.

$a=get-scomalert -Criteria "ResolutionState!='255' and IsMonitorAlert='$true'"
foreach($i in $a){
# get dot name of monitor that generated the alert
$z=$i.name
$b=$i.MonitoringRuleId.Guid
$c=Get-SCOMMonitor -id $b
$d=$c.name
$e=$c.Target.Identifier.Path
$csv+="$z, $d, $e`r"
}
$csv | out-file c:\temp\Alert_reset.csv

Comments