Custom activities, actions, and tables

The ITSM Adapter service provides a set of Custom Activities, Actions, and tables through the Citrix ITSM connector plug-in. With them, developers can create Citrix ITSM workflows that best suit your needs:

  • With the Activities, developers can create workflows for Citrix apps and desktops by using the ServiceNow Workflow Editor.

    Activities are building blocks of ServiceNow workflows. The Citrix ITSM connector plug-in provides Custom Activities for Citrix apps and desktops. Take the Get Sessions Activity as an example. It retrieves information about Citrix app and desktop sessions based on variable values.

  • With the Actions, developers can create workflows for Citrix apps and desktops by using the ServiceNow Flow Designer.

  • With the tables, you can retrieve data from Citrix environments.

For more information, see the Citrix ITSM developer documentation.

Activity: Run PowerShell scripts on a machine

With the Run PowerShell scripts on a machine Custom Activity, you can remotely run PowerShell scripts on a target machine.

Overview

The following diagram illustrates the processing flow of this Custom Activity.

Remote PowerShell workflow

The detailed process is as follows:

  • 1 and 2: The Citrix ITSM connector plug-in collects data from the activity and sends it to the Citrix ITSM Adapter service.
  • 3: The Citrix ITSM Adapter service parses the received data and sends it to the target Cloud Connectors.
  • 4: The Cloud Connectors parse the received data and deliver the script to the target machine for execution.
  • 5, 6, and 7: The target machine runs the script and returns the result to ServiceNow. In the process, HTTPS, WebSocket, and WinRM protocols are used.

This activity contains the following data:

  • Customer ID and resource location ID. Identify the Cloud Connectors for script delivery.
  • Machine Name. Identifies the target machine to run the script.
  • User name and password. Identify the credentials to run PowerShell on the machine.
  • Script. Identifies the PowerShell script.

For more information, see Run PowerShell scripts on a machine in the Citrix ITSM developer documentation.

Prerequisites

Before you use this Activity, you must:

Get started using the sample workflow

The ServiceNow Service Management Portal provides a sample workflow to help you understand how to use this Custom Activity.

To experience this sample workflow as a user, follow these steps:

  1. In the ServiceNow Service Management Portal, go to Citrix IT Service Management Connector > Services > Citrix Virtual Apps and Desktops.
  2. Click Run PowerShell scripts on a machine (sample workflow).
  3. Search for a target machine using the user name, delivery group, or machine catalog (any or all), and then select a machine from the search results.
  4. In the User Name and Password fields, enter the credentials for running the PowerShell script on the machine.
  5. In the Script Content field, enter the PowerShell script to run on the machine. Starting with the ITSM Adapter service version 23.7.0, you can use parameters in the script. Parameters are represented as ${ScriptParameters.<key>}. Each key name corresponds to a different parameter, such as ${ScriptParameters.ExampleParam1} and ${ScriptParameters.ExampleParam2}.
  6. If you’re using parameters in the script, in the Script Parameters field, enter key-value pairs using the JSON format to assign values to the keys in the script. Example, {"ExampleParam1":"Value1","ExampleParam2":"Value2"}
  7. Click Submit.

Example

Script Content:

$processes = Get-Process -Name “${ScriptParameters.appname}”
foreach ($process in $processes){
    Stop-Process -id $process.Id
}

<!--NeedCopy-->

Script Parameters:

{"appname":"chrome"}

Final script:

$processes = Get-Process -Name “chrome”
foreach ($process in $processes){
    Stop-Process -id $process.Id
}
<!--NeedCopy-->

To view design details of this workflow, follow these steps:

  1. On the ServiceNow Service Management Portal, select Workflow Editor in the left navigation menu.
  2. On the Workflows tab, select the CTX Remote PowerShell workflow. Its design details appear.
Custom activities, actions, and tables