Bulk resetting SCOM DHCP monitor alerts

I have 482 Warning Alerts for “DHCP IPv4 Scope Reconcile Required Monitor” with the reason “Orphaned entries were deleted due to the deletion of a class or an option definition”.

Capture

I have reconciled all of the scopes but is there a way to bulk Reset these alerts? It’s not feasible to do them 1 at a time.

From the topic recalculate-not-reset-monitors-in-bulk would Example 1 work if RecalculateMonitoringState was replaced with ResetMonitoringState. The RecalculateMonitoringState could then be run afterwards to update states.
The alert search would use “$Alerts = Get-SCOMAlert -Name ‘DHCP IPv4 Scope Reconcile Required Alert’ | where {$_.IsMonitorAlert -eq $true } so only thye ones I am interested in would be affected.”
I obviously don’t want to break anything so need advice before I run anything.
I think there are quite a few times when this would be helpful.

Cheers,
Ian.

Hi Ian

Yes, you can use ResetMonitoringState to reset the monitor on the source object for the alert. I’ve previously done something like.

$ManagementServerName = '.'
$AlertNameFilter = 'DHCP IPv4 Scope Reconcile Required Alert' # Alert Name filter i.e. 'DHCP IPv4 Scope Reconcile Required Alert' or '*' or 'Cluster*) etc...
$AlertStates = (0) # if you have any alert states other than New (0) add the values to this array i.e. (0,10,15)

Import-Module OperationsManager
New-SCOMManagementGroupConnection -ComputerName $ManagementServerName
$Alerts = Get-SCOMAlert -ResolutionState $AlertStates -Name $AlertNameFilter

foreach($Alert in $Alerts){
    if($Alert.IsMonitorAlert){
        # It's a monitor based alert we need to reset the health of the monitor that generated it        
        $Alert.Update("Monitor health state reset by script")
        (Get-SCOMClassInstance -id $Alert.MonitoringObjectId).ResetMonitoringState($Alert.MonitoringRuleId) | Out-Null

    }else{
        # it's a rule based alert we can just close it. 
        $Alert.ResolutionState = 255
        $Alert.Update("Alert closed by script")
    }
}

Hope that helps
Keith

1 Like

Hi Keith,
Thanks very much for your answer. Looks to do just what I want. Cheers, Ian.

1 Like