Creating ServiceNow incident using PowerShell script and SOAP

In the following procedure, we update the alert message definition and add a script recipient that executes a Microsoft PowerShell script. The script contains a SOAP message that creates ServiceNow incidents within Configuration Item 'DCRUM ', Category 'Network '. When the alert is raised to the report server, the notification appears in ServiceNow Incidents.

Before you proceed, make sure you have customized your ServiceNow service to receive SOAP messages. For more information, see Customizing ServiceNow SOAP Web Services.

Copy the following script to the report server in the c:\PowerShellAlert folder and name the file: dcrum-to-service-now-incident-soap.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 incident and {urlHostBase}https://my-instance.service-now.com/textsearch.do?sysparm_view=text_search&
sysparm_search=DCRUM_{sTS}_{eTSzdata}_{encodeURL(13)} 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.

Note

For the list of parameters that can be inserted in 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.
    Example:
    -command 'C:\PowerShellAlert\dcrum-to-service-now.ps1'
    -message '{notificationMessage}'
    -service_now_uri 'https://my-service-now.service-now.com/imp_notification.do?SOAP'
    -service_now_user_name 'john.smith'
    -service_now_password 'secretPassword123'
    -dcrum_url 'https://my-dcrum'
    

Where:

  • command = the local path to the script to be executed when the alert is triggered.
  • message = the alert message from NAM (as displayed in an alert e-mail and report server alert log).
  • service_now_uri = the ServiceNow SOAP endpoint.
  • service_now_user_name = a ServiceNow user name with authorization to create incidents or events.
    For more information, see Configuring ServiceNow User and assigning roles.
  • service_now_password = the ServiceNow password for the user with authorization to create incidents or events.
  • dcrum_url = a hyperlink to the NAM report with alert details that should be presented in ServiceNow.

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 the alert notification setup.

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

Click Save and Publish.