Scripts
Overview
The Scripts section in the IT Automation module on the Unified Dashboard allows IT administrators to manage and maintain a library of script automations. These automations can be seamlessly accessed and executed directly through the bot.
Scripts are supported on both Windows and macOS devices. The operating system you select while creating a script determines the script language, the execution options available, how the script is run on the device, and which devices you can test it on — so pick it carefully. Once saved, the operating system cannot be changed for that script.
New script addition
Here's how IT admins can add a new script using the dashboard:
-
Click the "Add script" button in the top-right corner of the dashboard.

-
Enter basic details such as the script name, version, description, and operating system. You can also add tags to categorize the scripts.

-
Now add script details by either selecting from popular options available on the platform or by entering your own script information.

To add a script from scratch, please provide the following details:
- Script type (Windows only): Choose whether the script is a Batch or a PowerShell script. Batch is the default. This field is not shown for macOS, where scripts are always shell (bash) scripts.
- Mode: Indicate the script type—whether it should proceed silently or require user interaction.
- Account type: Specify the privilege level the script should run with. The options are labelled per operating system:
- Windows — System or User
- macOS — Root or Local
- Script: Provide the script for automation or generate it using AI.
-
Finally, test your script by choosing a test device from the list mapped to the bot. The device list only shows devices matching the operating system selected in step 2. If testing succeeds, publish the script for end users. If testing fails, update the script details or select a different test device to try again.

A script can only be published after a successful test execution, and only if the script content still matches what was tested. If you edit the content after a successful test, run the test again before publishing.
Windows configuration
Script type
| Script type | Editor language | How it runs on the device |
|---|---|---|
| Batch (default) | Batch | Content is written to a .bat file and executed directly. |
| PowerShell | PowerShell | Content is written to a .ps1 file, which is launched through a small batch wrapper that calls PowerShell with -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass. |
Because PowerShell runs non-interactively, any host prompt in the script (for example, Read-Host) will fail immediately rather than hang invisibly. Ask for input using variables instead — see Variables in scripts.
Existing Windows scripts created before the Script type option was introduced are treated as Batch.
Mode and account type
| Account type | Mode | Behaviour on the device |
|---|---|---|
| System | Silent | Runs with full system privileges in the background. No UI is shown to the signed-in employee. |
| System | Interactive | Runs with full system privileges, but the script's windows and prompts are surfaced into the signed-in employee's session. Requires an active user session — if nobody is signed in, the execution fails with "No active user session". |
| User | Silent / Interactive | Runs as the employee mapped to the device, with that employee's privileges. Requires that specific employee to be signed in and their session to be active — otherwise the execution fails with "No user session found" or "Found non-active user session". |
Use System + Silent for unattended maintenance and inventory scripts. Use User only when the script must touch the employee's own profile, environment variables, or user-level registry hive.
macOS configuration
Script language
macOS scripts are always bash. The content is saved as a shell script and executed with /bin/bash. There is no Script type selector.
Mode and account type
| Account type | Mode | Behaviour on the device |
|---|---|---|
| Root | Silent | Runs as root in the background. No UI is shown. |
| Root | Interactive | Runs with administrator privileges through the macOS GUI, so any prompt or window is visible to the signed-in employee. Requires an active user session. In this combination, the Account type field is hidden on the dashboard because the script always runs as Root. |
| Local | Silent / Interactive | Runs as the employee mapped to the device. Requires that employee's session to be active. |
Interactive macOS scripts rely on an active GUI session. For fleet-wide maintenance on machines that may be locked, asleep at the login window, or unattended, use Root + Silent.
Generate with AI
Turn on the Generate with AI toggle to describe what you need in plain language instead of writing the script yourself.
- Enter a prompt (minimum 5 characters) describing the task, then click Generate script.
- Generation is operating-system aware. On Windows, the output targets CMD or PowerShell depending on the Script type you selected. On macOS, the output is bash — multi-line scripts are supported.
- Mode and Account type must be set before generating, as they influence the command that is produced.
- The generated script appears in the editor and remains fully editable. Use Clear prompt to start over.
- If the prompt is unclear or asks for something unsupported, the platform returns a message instead of a script — refine the prompt and try again.
Variables in scripts
Scripts support placeholders written as {{variable}}. These are resolved just before the script is dispatched to the device:
{USERNAME}— automatically replaced with the operating system username of the employee mapped to the target device. Preserve this exact spelling and casing; do not rename it.- Custom variables — any other
{{placeholder}}you add is detected automatically. When the script is triggered, the dashboard prompts for a value for each one.
If a placeholder cannot be resolved, the execution is rejected before anything runs on the device, so a malformed command is never dispatched.
Examples
:: Windows (Batch)
for /d %%D in ("C:\Users\{USERNAME}\*") do @echo %%D
# Windows (PowerShell)
Get-ChildItem -Path "C:\Users\{USERNAME}" -Directory | ForEach-Object { $_.FullName }
# macOS (bash)
ls -la "/Users/{USERNAME}/Documents"
Script details
The module's landing page displays a list of scripts with key details at a glance, including version, operating system, current status, addition method, tags, and who last updated them. It also offers filter and search options for quick discovery — including a filter by operating system. Clicking on any script item opens a detailed view with all configured information.

In the detailed view, the fields shown adapt to the script's operating system:
- Script type is displayed only for Windows scripts.
- Account type is shown as System/User for Windows and Root/Local for macOS, and is hidden altogether for macOS scripts in Interactive mode.
- The script body is syntax-highlighted as PowerShell, Batch, or shell depending on the operating system and script type.
Versioning
Once a script is published, its content becomes immutable to protect automations already in use. Editing the content of a published script creates a new version instead of overwriting the existing one, and you will be asked for a new version number. All versions stay linked to the same script, so past executions can always be traced back to the exact content that ran on the device.
Disabling a script
Published script can be disabled by selecting the "Disable" option from the three-dot menu on either the script row on the landing page or the details page. Once disabled, the script will no longer be available to employees on the bot, and any executions still pending for it are failed. Likewise, disabled script can be re-enabled in the same way.


Drafts
A script remains in draft state until it's published. During this time, details can be edited, or the script can be deleted from the three-dot menu on either the script row on the landing page or the details page.


Edit basic details
Basic details of published script can be edited by selecting the "Edit details" option from the three-dot menu, accessible on the script row on the landing page or the details page. The operating system cannot be changed once the script has been created.


Troubleshooting
Execution failures that relate to the operating system configuration usually map to one of the following:
| Status / message | What it means | How to resolve |
|---|---|---|
| No active user session | An Interactive script (Windows System, or macOS Root) was dispatched to a device where nobody was signed in. | Retry when the employee is signed in, or switch the script to Silent mode. |
| No user session found | A User (Windows) or Local (macOS) script was dispatched, but no session exists for the mapped employee. | Verify the device-to-user mapping under Configurations → Device mappings. |
| Found non-active user session | The mapped employee's session exists but is disconnected or locked. | Retry when the employee is actively signed in. |
| Agent not installed | No automation agent is registered against the device serial number. | Ensure the Leena desktop app is deployed on the device. |
| Agent not active / Offline | The agent is registered but currently has no connection to the platform. | Retry once the device is online; the request stays queued until the configured execution expiry. |
Full logs, exit codes, and the exact content that was dispatched are available for every execution under Reports → Scripts.
Updated 26 days ago
