Last active
August 29, 2015 14:10
-
-
Save jeffpatton1971/aeee67af3ed8a713101c to your computer and use it in GitHub Desktop.
A function to force a reset of the health state for an agent in Operations Manager 2012 SP1 and a function to remove a management gorup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Reset-HealthState | |
{ | |
param | |
( | |
$AlertName, | |
$ResolutionState | |
) | |
$Criteria = "Name like '$($AlertName)' and ResolutionState != $($ResolutionState)" | |
$Alerts = Get-SCOMAlert -Criteria $Criteria | |
ForEach($Alert in $Alerts) | |
{ | |
$Monitor = Get-SCOMMonitor -Id $Alert.MonitoringRuleId | |
Get-SCOMClassInstance -id $Alert.MonitoringObjectId | foreach {$_.ResetMonitoringState($Monitor)} | |
} | |
} | |
Function Remove-ManagementGroup | |
{ | |
# | |
# http://msdn.microsoft.com/en-us/library/hh329017.aspx | |
# | |
param ([string]$ManagementGroup) | |
$opsConfig = New-Object -ComObject AgentConfigManager.MgmtSvcCfg | |
$opsConfig.RemoveManagementGroup($ManagementGroup) | |
Restart-Service healthservice | |
} |
Just updated this to change the param MonitorName to AlertName since that's what we're really after here. Once we have the alerts then we pull the monitor Id from there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See http://www.system-center.me/opsmgr/reset-monitor-state-with-powershell for more details