Getting Started

Endpoints

Patch Management

Vulnerability Management

Software Deployment & IT Assets

Automation & Remote Desktop

Real-Time Reports & Alerts

Account Access & Management

SSO Authentication

Security Concerns

Need Help?

Action1 5 Documentation 5 Adding a New Script, Editing or Deleting Scripts

Adding a New Script, Editing or Deleting Scripts

Important! To add a new script, edit, or delete a script, a user role with Manage Scripts permission is required.

Adding a New Script to the Library

  1. Navigate to Configuration | Script Library.
  2. Select + New Script to launch the wizard.
  3. On the General step, enter the script name and description.
  4. On the Script step:
    1. Specify the script language (PowerShell, CMD, or Bash). To learn more about certain script types, refer to the Examples section below.
    2. Enter your script. You can type in the script body or upload a file.

Important! The upload option is recommended if you are using signed scripts. See Script Signing for details.

Adding a new script to the Script Library
      1. If necessary, specify exit codes for your script. It is recommended that your script exits:
        • with exit code 0 on success
        • with non-zero exit code if it encounters any error. In this case, you can instruct Action1 to initiate a reboot of the target endpoint.
      2. (for PowerShell and CMD scripts) In the Parameters section, click + Add parameter and specify the name, default value, and type for each parameter used in the script.

 

Tip: You can also provide new parameter values when configuring an automation to run this script.

NOTE: Configuration options for the Bash script parameters are not available within the wizard. You must specify parameter names and values in the script body. See the Examples section for details.

  1. On the Test step, verify the script operation. Select the target endpoint and click Run Script.

NOTE: If necessary, you can modify parameter values on this step.

Testing a new script in the Script Library
  1. Wait for the script execution to complete. Verify the results and finish the wizard.

A new custom script will appear in the Script Library

Examples

Example 1: PowerShell

  1. On the General step of the New Script wizard, enter:
      • Ping Host” as Name
      • Send a ping to the specified host.” as Description
  2. On the Script step, enter a sample PowerShell script:
# Make non-terminating errors throw:

$ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true try

{

# Run ping command

ping -i $TTL ${Host Name}

# In case where native exit codes don't throw:

if ($LASTEXITCODE -ne 0){

throw "ping failed with exit code $LASTEXITCODE"
  }

}

catch {

exit 245

}

NOTE: If a parameter name contains a space, enclose it in brackets as ${param name}, e.g., ${Host Name}

  1. In the Parameters section, click +Add parameter and define TTL and Host Name parameters, providing their names, default values, and types:
    1. Set TTL type to Int and value to 64
    2. Set Host Name type to String and value to www.google.com 
  2. If you want to initiate a reboot if the script fails, enter the exit code other than 0, e.g., 245.
  3. Finally, on the Test step, select the target endpoint where the script will be executed, and click Run Script.
    Tip: For testing purposes, you can enter a nonexistent host name to receive the exit code 245 and see if the reboot is initiated.

After completing the test run, click Finish.

Example 2: CMD

To create a sample CMD script that will send a ping to a certain host with a custom TTL value:

  1. On the General step of the New Script wizard, enter:
    • Ping Host” as Name
    • Send a ping to the specified host.” as Description
  1. On the Script step, proceed with a sample CMD script:
    @echo off
    ping -i %TTL% %Host Name%
  2. In the Parameters section, click +Add parameter and define TTL and Host Name parameters, providing their names, default values, and types:
    1. Set TTL type to Int and value to 64
    2. Set Host Name type to String and value to www.google.com 

The script will refer to these parameters using %param name% syntax. The parameter values will be passed to the script at run time as environment variables.

  1. Finally, on the Test step, select the target endpoint where the script will be executed, and click Run Script. After completing the test run, click Finish.

Example 3: Bash

NOTE: Parameter configuration using the wizard is not supported for Bash scripts, so you should provide the required values within the script body.

To add a Bash script that will send a ping to www.google.com  with a TTL=64:

  1. On the General step of the New Script wizard, enter:
  • Ping Host” as Name
  • Send a ping to the specified host.” as Description
  1. On the Script step, enter:

ping -i 64 www.google.com 

NOTE: Reboot option is not supported for Bash scripts.

  1. Finally, on the Test step, select the target endpoint where the script will be executed, and click Run Script. After completing the test run, click Finish.

Editing or Deleting Scripts

  1. To modify a built-in script, you should Clone that script using the Actions menu next to it, and then edit the copy.
  2. To delete your custom script, select it in the Script Library and from the Actions menu, click Delete.

NOTE: Built-in scripts cannot be deleted, as they are maintained by Action1.