Update resolution state with a script

This is a script you can use to update resolution state. It will look at all new alerts (resolutionstate = 0) and see if the alert description contains “domain” or “AD”, if they do, the script will set a new resolution state. The ID for the resolution state can be found under alert settings in the administration workspace, in the Operations Manager console. You can schedule task to run this script every X minute to update all new alerts.

$RMS = “myRMSHost”

Add-PSSnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”
Set-Location “OperationsManagerMonitoring::”
New-ManagementGroupConnection -ConnectionString:$RMS
Set-Location $RMS

$resState = 42 
$alerts = get-alert -criteria ‘ResolutionState =”0″‘ | where-object {($_.Description -match “AD”) -or ($_.Description -match “domain”)}
If ($alerts)  {
   foreach ($alert in $alerts)
    $alert.ResolutionState = $resState

The schedule task command can be

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -command C:\myscripts\change_resolutionstate.ps1

5 thoughts on “Update resolution state with a script

  1. Yes, as it is running PowerShell it should be enable to connect to the management group from any machine. You can also do this with Opalis if you have it around.

  2. Hi Anders, I use your script expanded with the possibility to read different alert desrcriptions from a file. This script consume a lot of CPU at the RMS. Is it possible to run it from a MS?

    TX in Advance

  3. Good post, but are you only sorting by “AD” og “domain”?

    I am using the following script:

    param ($rootMS)

    #Initializing the Ops Mgr 2007 Powershell provider
    add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client” -ErrorVariable errSnapin ;
    set-location “OperationsManagerMonitoring::” -ErrorVariable errSnapin ;
    new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin ;
    set-location $rootMS -ErrorVariable errSnapin ;

    $Alerts = get-alert -criteria ‘Name = ”Script or Executable Failed to run”’ | Where {$_.ResolutionState -eq 0}
    foreach($Alert in $Alerts)
    {$Alert.ResolutionState = 29
    $Alert.Update(“Resolution State Changed”)}

    And then this command:
    Powershell D:\ChangeResolutionState\SCOM\ScriptorExecutableFailedtorun.ps1 -rootMS MYRMS.domain

Leave a Reply

Your email address will not be published. Required fields are marked *