Recalculate, not Reset, monitors in bulk?

This is possible with PS, but in a super unintuitive fashion you don’t ask the monitor to reset but the object the monitor is attached to. You can either pass in a specific monitor guid (which will request recalculation on that monitor only) or you can omit this and just have all monitors on this object recalculate.

Disclaimer: Unlike resetting the health state, not all monitors support health state recalculation – so triggering this task may have no effect if they don’t. As such I’m going to assume you want to do this for specific alerts where you know the monitor does support it, or certain objects, but ultimately you can use any technique that gets you the object you want to reset health for and (optionally) the monitor id.

Example 1

#Recalculate all currently open monitor-based Alerts… ideally be more specific with your Get-SCOMAlert filtering
$Alerts = Get-SCOMAlert -ResolutionState 0 | where {$_.IsMonitorAlert -eq $true }
Foreach ($alert in $alerts)
{
	$monitoringObject = Get-SCOMClassInstance -Id $alert.MonitoringObjectId
	$monitoringObject.RecalculateMonitoringState($alert.MonitoringRuleId)
}

Example 2

#Recalculate all monitors for a specific object, in this case a Health Service Watcher for server MyServerName
$agentWatcherClass = Get-SCOMClass -Name ‘Microsoft.SystemCenter.HealthServiceWatcher
$agentWatcher = $agentWatcherClass | Get-SCOMClassInstance | where {$_.DisplayName -match ‘MyServerName’} | Select -First 1
$agentWatcher.RecalculateMonitoringState()

Hope that helps!

1 Like