> 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/da/powershell-kommandoer/invoke-psuscript.md).

# Invoke-PSUScript

Invoke-PSUScript starter et nyt job for at køre et script i PowerShell Universal og returnerer et job, som De kan følge for fremdrift og output.

## Synopsis

Starter et nyt PowerShell Universal-job for et script.

## Syntaks

```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]`. Scriptparametre eksponeres også dynamisk, hvor det er muligt.

## Beskrivelse

Starter et job, der kan spores via job-cmdletterne. Vælg et script efter navn, id eller scriptobjekt (som accepterer pipelineinput). Almindelige scriptparametre eksponeres dynamisk. Skjulte scriptparametre eksponeres bevidst ikke som dynamiske cmdlet-parametre, men kan angives via hashtabellen `-Parameters` og sendes til scriptet. Her er `-Credential` en PSU-legitimationsoplysning *variabel* til jobbet, ikke en `PSCredential` til godkendelse i Management API.

## Eksempel

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

## Parametre

| Parameter                | Beskrivelse                                                             |
| ------------------------ | ----------------------------------------------------------------------- |
| `-Script`                | Scriptobjekt, der skal udføres; accepterer pipelineinput.               |
| `-Id`                    | Numerisk id for det script, der skal udføres; accepterer pipelineinput. |
| `-Name`                  | Navn eller sti til det script, der skal udføres.                        |
| `-Environment`           | Tilsidesættelse af kørselsmiljø (alias `-PowerShellVersion`).           |
| `-Credential`            | PSU-legitimationsoplysningsvariabel, der bruges til jobbet.             |
| `-Notes`                 | Noter, der er gemt sammen med jobbet.                                   |
| `-WaitForDebugger`       | Venter på en debugger, før jobbet kører.                                |
| `-Wait`                  | Venter på, at jobbet afsluttes.                                         |
| `-WaitTimeout`           | Timeout for ventetid, i sekunder.                                       |
| `-Queue`                 | Jobkø eller computergruppe (alias `-ComputerGroup`).                    |
| `-Parameters`            | Hashtable med scriptparameterværdier, herunder skjulte scriptparametre. |
| `-Tags`                  | Mærker, der skal knyttes til jobbet.                                    |
| `-Silent`                | Undertrykker udførelsesoutput i den aktuelle pipeline.                  |
| `-ComputerName`          | URL eller værtsnavn for PSU-målserveren (alias `-Uri`).                 |
| `-AppToken`              | App-token til Management API.                                           |
| `-UseDefaultCredentials` | Bruger de aktuelle Windows-legitimationsoplysninger.                    |
| `-Integrated`            | Bruger den procesinterne administrationsklient i PSU.                   |
| `-TrustCertificate`      | Ignorerer fejl ved certifikatvalidering.                                |
| `-Cookies`               | Genbruger godkendelsescookies til denne PowerShell-session.             |

## Tilladelser

Adgangstokenet kræver `automation.scripts.<script path>/execute` for at køre denne cmdlet eksternt. Indlæsning af scriptparametrene kræver også `automation.scripts.<script path>/read`. Opslag af scriptet kan desuden kræve `automation.scripts/read` eller `automation.scripts.<name>/read`, når `-Name` bruges. Uden `-Wait` kræver læsning af det nye job `automation.jobs.<job ID>/read` eller jobbets konfigurerede 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/da/powershell-kommandoer/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.
