Was working on setting up some command line notifications this week and ran into an issue I didn’t find documented anywhere so thought I’d post it here.
When using command line notifications it is often of interest to pass command line variables to the program being called. One such variable is to specify the web console URL and associated alert ID of the alert that generated the notification so an operator can click the URL to see details about the alert.
Selecting the web console URL and alert ID in combination is as easy as choosing the WebConsole Link variable from the fly-out menu as shown
This will populate the command line with the variable – "$Target/Property[Type="Notification!Microsoft.SystemCenter.AlertNotificationSubscriptionServer"]/WebConsoleUrl$?DisplayMode=Pivot&AlertID=$UrlEncodeData/Context/DataItem/AlertId$"
This variable includes both the web console URL and the alert ID. The problem is – the alert ID variable doesn’t resolve when used in command line notifications – it works fine elsewhere just not for command lines. If you use this variable through command lines you will see a web console and alert link similar to the following:
The workaround for this issue is easy, just use the variable $Data/Context/DataItem/AlertId$ for the alert ID instead of the one available on the flyout.
A working WebConsole Link variable would appear as follows – "$Target/Property[Type="Notification!Microsoft.SystemCenter.AlertNotificationSubscriptionServer"]/WebConsoleUrl$?DisplayMode=Pivot&AlertID=$Data/Context/DataItem/AlertId$"