For the complete documentation index, see llms.txt. This page is also available as Markdown.

Invoke-PSUScript

SYNOPSIS

Starts a new PowerShell Universal job for a script.

SYNTAX

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

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.

Last updated

Was this helpful?