OM: Как закрыть активные алерты для здоровых мониторов

В Operations Manager иногда бывают ситуации, когда монитор переходит в здоровое состояние, но алерт продолжает висеть во вкладке активных алертов. В большинстве случаев это следствие ошибок оператора. Очень часто бывает, что система уже закрыла алерт, но оператор в это время заполняет поля алерта и возвращает ему прежнее состояние. Такой алерт самостоятельно уже не закроется. Чтобы не искать такие алерты вручную, можно воспользоваться следующим скриптом:

$Server = "ServerName"
$Credentials = Get-Credential
New-SCOMManagementGroupConnection -ComputerName $Server -Credential $Credentials
$ActiveAlerts = Get-SCOMAlert -Criteria "IsMonitorAlert = 1 AND ResolutionState < 255"
foreach ($Alert in $ActiveAlerts)
{
	$MonitoringRule = Get-SCOMMonitor -Id $Alert.MonitoringRuleId
	$MonitoringObject = Get-SCOMMonitoringObject -Id $Alert.MonitoringObjectId
	$MonitorList = New-Object System.Collections.Generic.List[Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitor]
	$MonitorList.Add($MonitoringRule)
	$MonitoringState = $MonitoringObject.GetMonitoringStates($MonitorList)
	if ($MonitoringState.HealthState -eq [Microsoft.EnterpriseManagement.Configuration.HealthState]::Success)
	{
		$Alert
		$Alert | Resolve-SCOMAlert -Comment "The alert was manually closed because the monitor is in healthy state."
	}
}

Необходимо задать переменную $Server, указав имя сервера управления Operations Manager, после чего запустить скрипт.