Triggers
Triggers require a license.
Triggers automatically start PowerShell Universal scripts when platform events occur. Use them for global error handling, notifications, integrations, and event-driven automation.
Triggered jobs do not start additional triggers. Triggers are stored in
triggers.ps1.
Trigger events
You can create triggers for the following events:
Job Started, Cancelled, Completed, Completed with Error, Requesting Feedback, Failed, and Timed Out
App (Dashboard) Started, Stopped, and Session Expired
Event Hub Connected and Disconnected
Health Check Failed
Server Started and Stopping
New User Login and User Login
Use of a Revoked App Token
API Authentication Failed and API Error
Git Sync
License Expired and License Expiring
Computer Offline
Notification Created
Notification Created
The Notification Created event runs when PowerShell Universal creates a notification through the notification service or Notification API. Use it to route platform alerts to systems such as Teams, email, ticketing, or monitoring tools.
The trigger script receives the created notification in the $Notification parameter. It includes the notification ID, title, description, level, creation time, source job, script, dashboard, license, identity, and stack trace when available.
Create the trigger in Automation > Triggers by selecting Notification Created as the event type, or define it in a configuration repository:
Notifications generated when a triggered job starts do not raise this event. This prevents notification triggers from recursively creating more notification-triggered jobs.
New User Login
The New User Login event occurs when a user first accesses PowerShell Universal. The script receives a $User parameter with user information.
User Login
The User Login event occurs when a user accesses PowerShell Universal. The script receives a $data parameter with user information.
Use of a Revoked App Token
The revoked app-token event occurs when a revoked app token is used. The script receives a $data parameter containing the app-token contents as a string.
Git Sync
The Git Sync event occurs for both successful and unsuccessful Git synchronizations. The script receives a $data parameter with the Git status.
Computer Offline
The Computer Offline event provides the computer object in the $Data parameter.
Global triggers
Global triggers run the assigned script whenever the selected event occurs. For example, this trigger runs Script.ps1 whenever any job starts:
Resource triggers
Resource triggers run only when an event occurs on the selected resource. For example, this trigger runs when the selected dashboard stops:
Event metadata
A job created by a trigger receives metadata about the event that invoked it. Job triggers receive a $Job parameter and dashboard triggers receive a $Dashboard parameter. Server-status triggers do not receive a parameter. Notification triggers receive $Notification.
Conditions
Use the -Condition parameter of New-PSUTrigger to determine whether the trigger should run. The condition runs locally on the server and must return $true or $false.
For example, this condition runs only when the Environment environment variable is set to production:
PowerShell cmdlets
Manage triggers with New-PSUTrigger, Get-PSUTrigger, Set-PSUTrigger, and Remove-PSUTrigger.
Last updated
Was this helpful?