> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/powershell-commands/invoke-psuscript.md).

# Invoke-PSUScript

Invoke-PSUScript starts a new job to run a script within PowerShell Universal, returning a job you can track for progress and output.

## SYNOPSIS

Starts a new PowerShell Universal job for a script.

## SYNTAX

```powershell
Invoke-PSUScript -Script <Script> [-Environment <String>] [-Credential <Variable>] [-Notes <String>] [-WaitForDebugger] [-Wait] [-WaitTimeout <Int32>] [-Queue <String>] [-Parameters <Hashtable>] [-Tags <Tag[]>] [-Silent] [<ConnectionOptions>] [<CommonParameters>]
Invoke-PSUScript -Id <Int64> [-Environment <String>] [-Credential <Variable>] [-Notes <String>] [-WaitForDebugger] [-Wait] [-WaitTimeout <Int32>] [-Queue <String>] [-Parameters <Hashtable>] [-Tags <Tag[]>] [-Silent] [<ConnectionOptions>] [<CommonParameters>]
Invoke-PSUScript -Name <String> [-Environment <String>] [-Credential <Variable>] [-Notes <String>] [-WaitForDebugger] [-Wait] [-WaitTimeout <Int32>] [-Queue <String>] [-Parameters <Hashtable>] [-Tags <Tag[]>] [-Silent] [<ConnectionOptions>] [<CommonParameters>]
```

`<ConnectionOptions>`: `[-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]`. Script parameters are also exposed dynamically where possible.

## DESCRIPTION

Starts a job that can be tracked through the jobs cmdlets. Select a script by name, ID, or script object (which accepts pipeline input). Normal script parameters are exposed dynamically. Hidden script parameters are deliberately not exposed as dynamic cmdlet parameters, but can be supplied through the `-Parameters` hashtable and are passed to the script. Here `-Credential` is a PSU credential *variable* for the job, not a `PSCredential` for Management API authentication.

## EXAMPLE

```powershell
Invoke-PSUScript -Name 'Deploy.ps1' -Parameters @{ Region = 'westus'; InternalToken = $token }
```

## PARAMETERS

| Parameter                | Description                                                               |
| ------------------------ | ------------------------------------------------------------------------- |
| `-Script`                | Script object to execute; accepts pipeline input.                         |
| `-Id`                    | Numeric ID of the script to execute; accepts pipeline input.              |
| `-Name`                  | Name or path of the script to execute.                                    |
| `-Environment`           | Execution environment override (alias `-PowerShellVersion`).              |
| `-Credential`            | PSU credential variable used for the job.                                 |
| `-Notes`                 | Notes stored with the job.                                                |
| `-WaitForDebugger`       | Waits for a debugger before the job runs.                                 |
| `-Wait`                  | Waits for the job to finish.                                              |
| `-WaitTimeout`           | Timeout for waiting, in seconds.                                          |
| `-Queue`                 | Job queue or computer group (alias `-ComputerGroup`).                     |
| `-Parameters`            | Hashtable of script parameter values, including hidden script parameters. |
| `-Tags`                  | Tags to attach to the job.                                                |
| `-Silent`                | Suppresses execution output in the current pipeline.                      |
| `-ComputerName`          | Target PSU server URL or host name (alias `-Uri`).                        |
| `-AppToken`              | App token for the Management API.                                         |
| `-UseDefaultCredentials` | Uses current Windows credentials.                                         |
| `-Integrated`            | Uses the in-process management client inside PSU.                         |
| `-TrustCertificate`      | Ignores certificate validation errors.                                    |
| `-Cookies`               | Reuses authentication cookies for this PowerShell session.                |

## PERMISSIONS

The access token requires `automation.scripts.<script path>/execute` to run this cmdlet remotely. Loading the script parameters also requires `automation.scripts.<script path>/read`. Looking up the script may additionally require `automation.scripts/read` or `automation.scripts.<name>/read` when using `-Name`. Without `-Wait`, reading the new job requires `automation.jobs.<job ID>/read` or the job's configured ReadPermission.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/powershell-commands/invoke-psuscript.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
