Time to upgrade! NAM is scheduled for end of support. It's time to move to Dynatrace our all-in-one software intelligence platform.

Creating ServiceNow event using PowerShell script and REST

Before you proceed, make sure you have customized your ServiceNow Web Services to receive REST messages. For more information, see Customizing ServiceNow Security Policies and Profiles.

Copy the following script to a report server in the c:\PowerShellAlert folder and name the file: dcrum-to-service-now-event.ps1

Open the Alert management screen.

In the Alerts list, locate the Network performance site alert and, in the Actions menu for that alert, select Edit notifications.

Append the following lines to the message notification definition:

Reference number: DCRUM_{sTS}_{eTSzdata}_{encodeURL(13)}
{view network performance details in CAS}{true}{false}

%5Emessage_keySTARTSWITHNETS_s{sTS}_e{eTSzdata}_{encodeURL(13)}}{view event in ServiceNow}
  • The first line builds a reference number from available parameters:
    • {sTS} - Last sample end timestamp
    • {eTSzdata} - Last sample timestamp
    • {encodeURL(13)} - Encode URL in parameter {13} which is Site .
  • The second line builds a URL to a ServiceNow search result for the reference number built in the first line.
    For the list of parameters that can be inserted into the message definition, click gear.

Select the Script tab and, if no script recipients have been defined, click Recipient Configuration.

Select the Scripts tab and click Add to add a script recipient.

Provide the following:

  • Description for the notification recipient.
    Example: ServiceNow REST Incident
  • Executable for the exact path to the script interpreter.
    Example: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • Parameters for the location of the script, the notification message, and information on your ServiceNow account.
-command 'C:\PowerShellAlert\dcrum-to-service-now-event.ps1'
-dcrum_message '{notificationMessage}'
-dcrum_uri ' {buildLink}{/LSServlet?dmiAction=Generate&lsAction=LoadByName&lsEntryName=Metric
{view network performance details in CAS}{false}{false}
-sn_node  '{14}'
-sn_resource '{13}'
-sn_msg_key 'NETS_s{sTS}_e{eTSzdata}_{encodeURL(13)}'
-sn_uri  'https://my-service-now.service-now.com/api/now/table/em_event'
-sn_user_id 'john.smith'
-sn_passwd 'secretPassword123'


  • command = a local path to the script to be executed once the alert is triggered.
  • dcrum_message an alert message from NAM (as displayed in an alert e-mail and report server alert log)
  • dcrum_uri = a hyperlink to NAM report with alert details to present in ServiceNow
    The dcrum_uri parameter is an active link that is inserted into a custom field that needs to be defined and mapped in the ServiceNow system. For more information, see Customizing ServiceNow Incident Form.
    • In Step 4 of customizing the ServiceNow form, make sure you select “URL ” as the type of your custom field.
    • For the ServiceNow system to insert the URL parameter value into an Incident form, your PowerShell script must process the URL value. By adding $dcrum_uri = $dcrum_uri -replace '([\w\s]+): ', '', you remove any automatically added prefixes to the URL.
  • sn_node = a node that will be reported to ServiceNow Event (for example, Europe for location alert)
  • sn_resource = a resource that will be reported to ServiceNow Event (for example, Gdansk for location alert)
  • sn_uri = ServiceNow REST endpoint: https://my-instance.service-now.com/api/now/table/em_event
  • sn_user_id = ServiceNow user name with authorization to create incidents or events
  • sn_passwd = ServiceNow password for the user with authorization to create incidents or events
  • debug = an optional setting, which, if set to 1, appends the file service-now.log with debug information

Click Save and Close to return to the Alert notifications screen.

In the Alert recipient list, click the Actions menu corresponding to alert recipient you have just created and select Enable notifications.

Click Finish to complete alert notification setup.

On the summary screen, click Apply to confirm your changes to the configuration.

Click Save and Publish.