SCOM PS not able to display property bag value in Alert description

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()

** some code **

$PropertyBag.addvalue(“Desription”,$global:messages)

if($global:messages -match “missing”)
{
$PropertyBag.AddValue(“state”,”ERROR”)

}
$PropertyBag

Hi. Is this post I did earlier on using the powershell pack any help?

(copy and paste below link, I couldn’t create a direct link as this forum kept reformatting it and doing weird things)

https://goo.gl/1BMcsG

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.

1 Like

The community site sure does have some kinks that need ironing out :wink:

You might also see Parameter Replacement Failure alerts if you have wrongly configured the variables in your alert description.

thanks a lot for finding out spelling mistake and after fixing it. SCOM printed description correctly. Thanks a lot