> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neoagent.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute PowerShell on Device

> Let an agent write a PowerShell script and run it on one RMM device, after a technician approves the exact script and device

The agent writes a PowerShell script for the ticket and runs it on one device through your RMM. A technician approves every run: the approval card shows the device, its company, the RMM and the whole script, and only that script runs on that device.

Use [Execute RMM Script](https://docs.neoagent.io/agents/tools/rmm/run-rmm-script.md) for scripts that are already in your RMM library. This tool is for a script the agent writes itself.

Triggered and scheduled agents only; chat agents cannot run Neo-written PowerShell, because in a chat the person who asks would approve their own request. The agent's run must start from a PSA event, a schedule or a person: a run another agent started (a hand-off from a chat or from another agent) cannot run it.

> [!WARNING]
>
> The script runs as the RMM agent's account on the device, usually SYSTEM, with full control of the device. Approve only a script you have read and understand.

## Turn it on

**1. Grant script execution**

On the agent's **Tools & Settings** tab, under **RMM**, set the RMM's script-execution permission group to **Read & Write**: NinjaOne, Kaseya VSA X or ConnectWise Platform **Automation**, Datto RMM **Jobs**, N-Sight **Tasks**, or ConnectWise Automate **Script Execution**.

**2. Turn on Run PowerShell Neo writes**

On the same group, turn on **Run PowerShell Neo writes**. It is off by default. Turn it on for each RMM whose devices the agent may run scripts on.

**3. Check the Neo wrapper script**

The RMM needs the `[Neo Script] Run Powershell` script in its library, the same one the on-premises Active Directory and Exchange tools use. ConnectWise Platform uses its built-in **PowerShell script** template.

You can also ask your Neo Support Agent to turn the switch on for an agent.

## How a run works

1. The agent finds the device with [Get Synced Devices](https://docs.neoagent.io/agents/tools/rmm/synced-devices.md) and writes the script.
2. The agent asks for approval with the exact call. Neo writes the card from that call: the device, its company, the RMM and the whole script. Code and text that imitate Neo's block in the agent's own request text are removed from the card.
3. You approve without a note. The script runs on that device once.
4. The agent waits for the job and reads the output, as with any RMM script.

## Approval rules

| Rule | Behavior |
| - | - |
| **Every run asks** | **Require Technician Approval** off, **Pre-approved scripts** and custom instructions never skip the approval |
| **Exact match only** | The approved script, device and ticket must match the call exactly. A changed script or device needs a new approval |
| **One run per approval** | One approval allows one run. To run the script again, for example after it failed, the agent asks again |
| **Approve with note** | Does not run the script. Use **Ask for changes** to send it back |
| **One script per request** | A request shows one script, so you read it whole |
| **Length** | At most 3,000 characters, so the whole script fits on the Teams card. The agent splits longer work into smaller scripts. A request whose card would still be too large for Teams, for example a script with many non-ASCII characters, goes out without the run, and the agent shortens it |
| **Started by a PSA event, a schedule or a person** | A run that another agent started, directly or through a chain of hand-offs, is refused |
| **No secrets** | A script that holds a password, key or token is refused before any approval |
| **Shown as it runs** | A script with invisible or text-reordering characters, control characters, a line starting with ` ``` ` or `~~~`, or anything that decodes hidden content (`-EncodedCommand`, Base64 or hex decoding) is refused before any approval. The card shows the script as plain text in a monospace font |
| **Downloaded code** | A script that downloads and runs code is not refused. Its card opens with: "This script downloads and runs code from the internet; the approval does not cover that code." |
| **Supervised runs** | Only an approval from the same run counts |
| **Test mode** | No script runs, reads included |

## Where it runs

* Windows devices of the RMMs above, where **Run PowerShell Neo writes** is on for the device's RMM.
* An automation with a ticket reaches only the ticket's company's devices.
* Not on N-able N-central, ScreenConnect, Syncro or Addigy devices.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.