I am using below powershell code to generate rule based scom alert and when I am trying to print property bag value in Alert response –> Alert Description, getting blank value. Can you please help me or provide me proper syntax to print property bag value in Alert Description.
Please let me know if you need any further information.
$ScomAPI = New-Object -comObject “MOM.ScriptAPI”
$PropertyBag = $ScomAPI.CreatePropertyBag()
Assuming the alert is firing ok but the description is missing, you just need to add $Data/Property[@Name=‘Description’]$ into your alert description (all case-sensitive), which will be automatically replaced when the alert is fired. It is worth noting btw that in your code above you’ve spelt ‘description’ incorrectly, so unless the same typo is replicated in your Alert Description that’ll be why it’s blank.
May also be worth checking the alert context (in Squared Up or the SCOM console) to make sure that whatever $global:messages contained was correctly converted to a string and added to the property bag ok.