DPM: Script to automatically resolving alerts

Alerts aren't generated to be dismissed without evaluation and some resolve automatically but there're moments when automatic handling of alerts is appreciated. More often than not alerts are predictably handled same anyway, namely using "recommended action" link. Some management activities are handled through alert mechanism, like reclaiming ownership of agents after switch back from a […]

Alerts aren't generated to be dismissed without evaluation and some resolve automatically but there're moments when automatic handling of alerts is appreciated. More often than not alerts are predictably handled same anyway, namely using "recommended action" link. Some management activities are handled through alert mechanism, like reclaiming ownership of agents after switch back from a prior switched protection. In this case, most likely you want to reclaim ownership of all protected servers and can be many.

By courtesy DPM team the script below automatically takes the recommended action and resolves active alert for all protected servers. The $alert.Servername property can be used to filter on machine names if desired. This can also be seen as a sample framework to handle alerts from a script. If further interested, last part of the script retrieves and displays all possible alert types, currently there're some 64 alert types.

#begin script

$dpmServer = Connect-DPMServer -DPMServerName $dpmServerName $dpmServer.AlertController.RefreshAlerts() 
$ownershipAlerts = @($dpmServer.AlertController.ActiveAlerts.Values | Where {$_.Type.ToString() -eq "AgentOwnershipRequiredAlert"} )

if ($ownershipAlerts){ 
   foreach ($alert in $ownershipAlerts) { 
       $alert.TakeRecommendedAction()$alert.ResolveAlert() 
   } 
}

$evals=[enum]::GetValues([microsoft.Internal.EnterpriseStorage.Dls.Utils.AlertTypes.AlertEnum]) 
write-host “Alert types are;” 
$evals

#end script

[Source]