Skip to content

Instantly share code, notes, and snippets.

@jeffpatton1971
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffpatton1971/aeee67af3ed8a713101c to your computer and use it in GitHub Desktop.
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
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
}
@jeffpatton1971
Copy link
Author

@jeffpatton1971
Copy link
Author

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