Powershell Script to resolve alerts with specific alertname

I needed a script to resolve 30,000+ alerts with the same name and found this script below on the internet, I tweaked and changed the script somewhat and it resolves 30,000+ alerts in a matter of minutes.

I’ve tested this script on OpsMgr 2k7 R2 only.


add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”;

$mgConn = New-ManagementGroupConnection -connectionString:$rms;

if ( $mgConn -eq $null )
[String]::Format(“Failed to connect to RMS on ‘{0}'”,$rms);

Set-Location “OperationsManagerMonitoring::”;
Set-Location $rms;

$criteria = [string]::Format(“Name = ‘{0}’ AND IsMonitorAlert = 0 AND ResolutionState < 255”,$alertName);

Get-Alert -Criteria $criteria | ForEach-Object {
    [String]::Format(“Closing Alert ‘{0}'”,$_.Name);
    $_ | Resolve-Alert -Comment “Closed by automation script” | out-null;   


To run, save the script as a .ps1 file, then use the following command:

.\script.ps1 –rms RmsName -alertName ‘Exact Alert Name’

The alertName is case sensitive.

This script will resolve all alerts that’s not created by a monitor.