# ============================================================================================== # # Microsoft PowerShell Source File -- Created with SAPIEN Technologies PrimalScript 2007 # # NAME: SCOM-UpdateResolution.ps1 # # AUTHOR: Jeremy D. Pavleck , Pavleck.Net - jeremy@pavleck.net # DATE : 7/3/2008 # # COMMENT: This script will look for alerts that match a given name, then change their resolution state # from New (0) to the defined state. Then you can create alert notifications based solely on that alert # resolution state. # # ============================================================================================== $alertName = "Pavleck.NET - Tutorial - Resolution State - Error 926" $resState = 10 # Our custom resolution state $RMS = "MYRMS" Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" Set-Location "OperationsManagerMonitoring::" New-ManagementGroupConnection -ConnectionString:$RMS Set-Location $RMS # Let's instantiate the SCOM API $momapi = New-Object -comObject "MOM.ScriptAPI" # Gather all the alerts in 'new' state and with our alert name $alerts = Get-Alert | Where-Object {$_.ResolutionState -eq 0 -and $_.Name -eq $alertName} # Now that we have our alerts, lets change the resolution state to our custom one. foreach ($alert in $alerts) { # Change resolution $alert.ResolutionState = 10 # Update the RMS $alert.Update("") }