Skip to content

Invoke-UAScript

SYNOPSIS

Invokes a script within UA.

SYNTAX

Script

Invoke-UAScript [-Script] <Script> [-WaitForDebugger] [-Environment <String>] [-Notes <String>]
 [-Credential <Variable>] [-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials]
 [<CommonParameters>]

Id

Invoke-UAScript [-Id] <Int64> [-WaitForDebugger] [-Environment <String>] [-Notes <String>]
 [-Credential <Variable>] [-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials]
 [<CommonParameters>]

Name

Invoke-UAScript [-WaitForDebugger] [-Environment <String>] [-Notes <String>] [-Credential <Variable>]
 [-Name] <String> [-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials] [<CommonParameters>]

DESCRIPTION

Invokes a script within UA. Invoking a script starts a new job that you can then track the progress of.

EXAMPLES

Example 1

PS C:\> $Script = Get-UAScript -Name 'Script1.ps1'
PS C:\> Invoke-UAScript -Script $Script

Invokes 'Script1.ps1'

Example 2

PS C:\> $Script = Get-UAScript -Name 'Script1.ps1'
PS C:\> Invoke-UAScript -Script $Script -Parameter1 123 -Parameter2 "Test"

Invokes 'Script1.ps1' with the parameters Parameter1 and Parameter2. These parameters will be passed to the script. Invoke-UAScript supports any number of dynamic parameters.

Example 3

PS C:\> $Script = Get-UAScript -Name 'Script1.ps1'
PS C:\> $Password = Get-UAVariable -Name 'UserPassword'
PS C:\> $Credential = New-UDCredential -UserName 'adam' -Password $Password
PS C:\> Invoke-UAScript -Script $Script -Credential $Credential

Invokes 'Script1.ps1' as the user 'adam'. Passwords are retrieved from secret managers and cannot be passed in as strings.

PARAMETERS

-AppToken

An app token to access the UA API.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ComputerName

The HTTP address of the UA REST API server.

Type: System.String
Parameter Sets: (All)
Aliases: Uri

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Credential

The credential of the user to run the script as. Use New-UACredential to create this credential.

Type: PowerShellUniversal.Variable
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Id

The ID of the script to invoke.

Type: System.Int64
Parameter Sets: Id
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Name

The name of the script to invoke.

Type: System.String
Parameter Sets: Name
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Notes

Notes to include with the job execution.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Script

The script to invoke. Use Get-UAScript to retrieve existing scripts.

Type: PowerShellUniversal.Script
Parameter Sets: Script
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-WaitForDebugger

Not used.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Environment

The environment to use when invoke this script. You can see available environments by using Get-PSUEnvironment.

Type: System.String
Parameter Sets: (All)
Aliases: PowerShellVersion

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-UseDefaultCredentials

Use default credentials when connecting to the management API

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

UniversalAutomation.Script

System.Int64

OUTPUTS

System.Object

NOTES

Get-PSUEnvironment

Back to top