Workspace Environment Management

Scripted Tasks

Tip:

Scripted tasks work at a machine level. To run tasks at a user session level, use External tasks instead.

This page lets you configure and automate scripted tasks to suit your environment management needs.

Create a scripted task

Scripts are categorized into two types: Built-in Scripts and Custom Scripts. Each type provides two viewing modes: a Script View and a Task View. All scripted tasks are executed at the configuration set level.

To create a task from a script, follow these steps:

  1. On the Scripted Tasks page, select Script View, locate the specific script, then click the Create task (+) icon.

  2. In the Create task wizard, configure the following settings:

  3. Click Done.

Note:

After you create a scripted task, you can manage it directly from the script list. Expand the script to display its tasks, then hover over a task row to access the View, Edit, and Delete action icons.

General

Configure the following settings on the General page:

  • Enable this task. Choose whether to enable (Yes) or disable (No) the task for the current configuration set. If disabled, the agent does not process the task.
  • Verify signature. Choose whether to verify the signature before running the task. Signature verification is mandatory when the scripted task is granted full access.
  • Task timeout. Choose whether to set a timeout (in minutes) for the task. When the timeout occurs, the task is forced to end. Supported values: 1–60. We recommend setting a timeout for the task. Otherwise, the task might be left running, preventing other tasks from running.

  • Filter. Choose whether to contextualize the task by selecting a filter. With a filter selected, this task runs only when all conditions in the filter are met. When selecting a filter, consider the following:

    • If the filter contains conditions that do not apply to scripted tasks, the agent skips those conditions when evaluating the filter before running the task. For a complete list of conditions that do not apply to scripted tasks, see Conditions not applicable to machine settings.

Triggers

Configure the following settings on the Triggers page:

  • Configure triggers for the task. You can do the following:

    • Select triggers that you want to associate with the task. When activated, those triggers start the task in the user environment.

    • Choose whether to show only triggers that apply to this task.

    • Create a new trigger. See Create a trigger.

    Note:

    To edit existing triggers, go to Triggers.

Parameters

Configure the following settings on the Parameters page:

  • Pass parameters to the scripted task. Choose whether to pass parameters to the scripted task. When enabled, lets you provide inputs as parameter variables in the scripted task at runtime. The benefit is that you can control how the scripted task behaves without changing the underlying code. The following parameter types are available:

    • Integer. Example: 123.
    • String. Example: hello world.
    • Boolean. Ture or False.
    • Character. Example: c.
    • Switch. Ture or False.
    • Double. Example: 1.023.
    • Date and time. Example: YYYY-MM-DD HH:mm:ss.
    • File path. Enter a path that you want to pass to the System.IO.FileInfo class. Environment variables are supported. The path must not include the following characters: * ? < >.

    Note:

    • You can configure up to 20 parameters.
    • The name field is optional except for parameters of the “switch” type.
    • PowerShell supports partial parameter names. When using a partial parameter name, make sure that the name is unique — disambiguate it from existing parameter names. Example: The following parameter names are the same for PowerShell: -t, -ti, and -title. In this case, supply enough letters of the parameter name to distinguish it from the other parameters.

Output

Configure the following settings on the Output page:

  • Output files. Choose whether you want to collect files that the task outputs. If selected, includes output file content in reports generated for the task. You can then view the output file content in the reports without the need to access the output files in the user environment.

  • Output highlights. Choose whether you want to highlight certain content in the output file content and the console output.

    • Highlight keywords. Specify keywords that you want the report to highlight. You can type multiple keywords, separated by commas. After typing a keyword, press Enter to continue. If specified, report contents that match your keywords will be highlighted in the Output file content and Console output sections in the generated reports.

    • Highlight regular expression matches. Enter a regular expression that describes the content you want to highlight. The regular expression must conform to the .NET regular expression library syntax, which is PCRE compatible. For more information, see the Microsoft documentation: https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference.

      • Regular expression. Enter a regular expression that describes the content you want to highlight.
      • Ignore case. Choose whether content must exactly match the case.
      • Use multiline matching. Choose whether to use multiline matching, where \^ and $ match the beginning and end of each line, instead of the beginning and end of the entire output content.
      • Capture only named groups. Choose whether to capture only named groups. Captured groups are defined by using parentheses in the regular expression pattern. Named groups are explicitly assigned a name or a number by the (?<name> subexpression) syntax.
      • Number of lines to include as context clues. Specify the number of lines before and after the match you want to include in the highlight as context clues. Supported values: 1–10.
      • Include only regular expression matches in reports. Controls whether to include the entire output content in reports or only content that matches the regular expression. Enabling this option reduces the amount of data transmitted to Citrix Cloud. With the option enabled, the Highlight keywords feature has no content to show regardless of the specified keywords.
  • Advanced options.

    • Collect output even if runtime errors occur. Controls whether to collect output file content and console output even if errors occur while running the task.

View reports for a scripted task

  1. On the Scripted Tasks page, click the tasks dropdown menu in the script row to expand its task list.

  2. Hover over a task to display the action icons.

  3. Click the View reports icon.

As a result, you are taken to the Monitoring > Reports page, where you see the reports (if any) related to the task. Click the ellipsis to view more detailed information. For details, see Reports.

Note:

To run a scripted task that’s set to Run as logged-on user, select a recently connected agent in Monitoring > Administration > Agents, and then select More > Run scripted task.

Scripted Tasks