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

New-PSUTrigger

Creates a new Automation trigger in PowerShell Universal.

SYNOPSIS

Creates a new Automation trigger in PowerShell Universal.

SYNTAX

New-PSUTrigger -Name <String> -EventType <EventType> -TriggerScript <Script> [-Script <Script>]
 [-Dashboard <Dashboard>] [-Environment <String>] [-Delay <Int32>] [-Computer <String>]
 [-Condition <ScriptBlock>] [-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>]
 [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]
 [<CommonParameters>]

DESCRIPTION

Creates a new Automation trigger in PowerShell Universal. Powershell Universal Automation triggers allow you to execute scripts based on events within PowerShell Universal. You can run scripts when other scripts fail, dashboards stop or when the server is starting up.

Triggers are stored within the ./universal/triggers.ps1 file.

You can also use this cmdlet to create triggers through the REST API.

EXAMPLES

Example 1

Creates a new trigger that calls the ScriptFailed.ps1 file when any job within PowerShell Universal fails.

Example 2

Creates a new trigger that calls the DashboardStopped.ps1 file when the dashboard MyDashboard stops.

Example 3

Creates a new trigger that calls the LogServerStart.ps1 file when the PowerShell Universal server is started.

PARAMETERS

-AppToken

The app token for accessing the PowerShell Universal Management API.

-ComputerName

The computer name or URL of the Powershell Universal server.

-Dashboard

Triggers for a specific dashboard.

-Environment

The environment to run the triggered script in.

-EventType

The event that causes this trigger.

-Name

The name of this trigger. This needs to be unique.

-Script

The script that causes this trigger.

-TriggerScript

The script to trigger when this trigger is triggered.

-UseDefaultCredentials

Use default credentials when connecting to the management API

-Delay

Specifies the delay between executions.

-Integrated

Executes the command internally rather than using the Management API. Only works when running script from within PowerShell Universal.

-Computer

The computer or queue to run this trigger on.

-Condition

A condition script block to determine whether or not to run this trigger.

-Credential

Credentials to login to the PowerShell Universal Management API.

-TrustCertificate

Whether the cmdlet should ignore certificate issues.

-Cookies

Reuses and persists authentication cookies for the current PowerShell session.

CommonParameters

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

INPUTS

None

OUTPUTS

System.Object

NOTES

Last updated

Was this helpful?