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 20 Reputation points
2023-04-17T12:53:17.0066667+00:00

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,493 questions
{count} votes

Accepted answer
  1. SChalakov 10,391 Reputation points MVP
    2023-04-21T21:14:13.75+00:00

    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"
    $myAlert.Update("")
    exit
    
    

    and I am using the following Command Channel Settings:

    • Full Path of the command file:

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

    • 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)
    Regards
    Stoyan Chalakov

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.