Skip to main content
Scripting

Level's scripting engine lets IT pros run commands on multiple devices at once, supporting PowerShell, Bash, Python, and more.

Updated over 4 weeks ago

Create and execute scripts across multiple devices

Scripts in Level allow technicians to run commands quickly on one or multiple devices. You can choose between two options: a new script or a saved script. Saved scripts are stored in your script library under the Automation tab. If you run a new script, it won’t be saved to your script library but will be recorded in the Script Runs section for later review if needed.


Managing Scripts

Saved scripts are now located under the Automations tab, where you can group and organize them as needed. You can create custom groups for your scripts based on their function, platform (e.g., Windows, macOS, Linux), or any other categorization that fits your workflow. This update makes it easier to manage large collections of scripts.

Scripts can now be grouped for better organization. When creating or editing a script, you can assign it to an existing group or create a new custom group. This allows you to organize scripts in a way that suits your needs, making it easier to locate and manage scripts across multiple platforms and devices.

Script Groups:

  • Custom Grouping: You have the flexibility to create your own groups and organize scripts according to your team's needs—whether by platform, task type, or any other criteria that make sense for your environment.

  • Group Management: From the Automations tab, you can view, edit, and delete script groups to ensure that your library remains organized and up-to-date.


Creating a script

Create a script by clicking Create Script on the script page. Or edit a script by selecting its name.

Create or edit a script using the script editor

  1. Name: The name of the script.

  2. Description: A description of the script.

  3. Language: The language the script was written in.

    • PowerShell

    • Bash

    • Zsh

    • Osquery

    • Python

    • Ansible

    • Go

  4. Timeout - How long to allow the script to run before exiting.

  5. Run as - Configure who the script is ran under, either System (Admin/Root) or as the Current User.

  6. Script Editor - The editor where you can write or paste your script.


Script Variables

Script Variables allow technicians to add variables to scripts, making them adaptable to different environments and needs. Variables act as placeholders within a script that can be customized each time the script is run, reducing the need to create multiple versions of similar scripts for different use cases.

How to Use Script Variables

1. Define Variables: When creating or editing a script, you can add variables by entering them into the Script Variables section. These variables can be referenced throughout the script by their name, making the script dynamic and adaptable.

2. Using Variables: Variables created in the script settings can be used directly within the script, or you can leverage custom fields, which can be set at the device, group, or global level, or be set by an automation. This flexibility allows variables to adapt based on the context in which the script is run.


Running scripts

There are several places where a script can be initiated.

  1. From the Device Listing, select the target devices, and then choose Actions -> Run script.

  2. From Device Details, on the top right choose Actions -> Run script from the dropdown.

  3. From an Automation, you can select the Run Script or Shell automation actions. This method allows you to run scripts across devices even if they are offline, as Automations will queue the execution until the device is next online.

  4. On a Monitor Policy, a monitor can run a script if the monitored threshold is exceeded.

Once a script is selected, clicking Review Script will create a new Script Run and place it in a newly created automation, which includes a wait for approval action. The script will not execute until it is approved. You can edit the script and add actions to the automation as needed. To include additional devices in the Script Run, click the Add a Device button or go to the Devices page, select the desired devices, and choose Add to Script Run.


As the script runs, you can click on the Devices icon to view the automation steps and the output of the script by selecting the Actions dropdown. You can also review this information in the History tab, which shows the devices the script has run on.


Script Runs

To view all script runs, navigate to the Automation tab and select Script Runs from the side menu. This will display a list of all the script runs you have completed, including how many times each has been executed, the date of the last run, and, by clicking into them, the output and history details.

Did this answer your question?