SCOM 2019 UR4 - Script to check alert and get the MP details and then add required custom fields for SCOM alerts (Monitor and Rule) for alert enrichment.

Ganesh 0 Reputation points

Service now pulls the alert from SCOM. but it is not capable to identify which alert needs to be sent to which support group. So need to add the support group detail in the custom field. Hence need a way/script to check the alert and identify the mp name and then based on it, add the support group name into the custom field of the alert. Any suggestion pls advise.

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,419 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SChalakov 10,271 Reputation points MVP

    Hi Ganesh, i am doing this in many different environments, using a SCOM command channel and a simple PowerShell script and it works like a charm. Here are the detailed steps: Update your alert custom fields with SCOM notification channels I am using the following script:

    Param([parameter(mandatory=$true)][GUID] $AlertID)
    #Load all assemblies
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.OperationsManager.Common") | Out-Null
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Core") | Out-Null
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.OperationsManager") | Out-Null
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Runtime") | Out-Null
    #Create the connection
    $mgConnSetting = New-Object Microsoft.EnterpriseManagement.ManagementGroupConnectionSettings($env:computername)
    $mg = New-Object Microsoft.EnterpriseManagement.ManagementGroup($mgConnSetting)
    #Receive alert information
    $myAlert = $mg.GetMonitoringAlert($AlertId)
    # Set the fields and update the alert
    $myAlert.CustomField7 = "YourGroupName"

    and I am using the following Command Channel Settings:

    • Full Path of the command file:


    • Command line parameters:

    -ExecutionPolicy Bypass -Command "& '"C:\Scripts\SCOMAlertUpdate.ps1"'" '$Data/Context/DataItem/AlertId$'

    Important note: As the script can be executed by any management server that is part of the notification ressource pool, you need to ensure that all the members of the pool have the folder with the script in it under the same file path. Please go through this: What account will command channel notifications Run As in SCOM?

    I hope I could help you with that. (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
    Stoyan Chalakov

    1 person found this answer helpful.
    0 comments No comments