Updated on 2024-09-04 GMT+08:00

Running PowerShell Scripts

This action aims to run the PowerShell scripts in a specified path on a Windows host. The following figure shows the configuration page.

Table 1 Parameters

Parameter

Description

Action Name

Name of an added deployment action. Max 128 characters. Do not start or end with a space. Use letters, digits, spaces, and these special characters: -_,;:./().

Environment

Select a host cluster as the deployment object.

Running Mode

Default and Background are available.

NOTE:
  • Default: The result is printed, but the related service or process cannot be started.
  • Background: The service or process can be started, but the result will not be printed.

Script Path

Path of the script on the target host.

Running Parameters

Before executing the script, set parameters. During script execution, the entered parameter values are loaded and used.

Control Options

  • Enable this action.
  • Continue the task even if this action fails.

How Do I Use PowerShell Script Execution Parameters?

  1. Use param($a,$b) at the beginning of the script to declare variables a and b.
  2. Use variables $a and $b in the script.
  3. When running the script, enter the values of variables a and b in the script running parameters and separate them with spaces.

    Example:

    The following figure shows the content of the hello.ps1 script. Set an environment variable to import a temporary value.

    Figure 1 Script content

    Configure parameters.

    Figure 2 Settings

  4. View the result.

    Figure 3 Result

If you encounter any problem during deployment, see Solutions to Common Problems.