Use this when choosing what starts a scheduled task.
Triggers
Task triggers start scheduled tasks: on a schedule, at startup, at logon, on idle, on a specific event log entry, or when a session connects or locks. One task can have several triggers.
1. (Get-ScheduledTask <name>).Triggers — type and schedule.
2. Enabled and not expired?
3. Time zone/synchronise across time zones?
4. Event triggers: correct log and XPath.
5. Test with Start-ScheduledTask.
trigger (time, logon, startup, event) → fires → task queued
Context & applicabilityCommon mistakes · platform/version boundaries
- "At log on" tasks that run for every user when only one was intended.
- Event triggers with XPath filters that never match — test with Event Viewer custom views first.
- Time triggers in local time causing double/missed runs at DST changes.
- Random delay not used, so hundreds of machines hit a server at the same second.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Triggers can be time, event, logon or startup.
- One task can have several triggers.
- Triggers can expire.
Get-ScheduledTask -TaskName <name> | fl *— task definitionGet-ScheduledTaskInfo -TaskName <name>— last run time and resultschtasks /query /tn <name> /v /fo list— details in CMDGet-WinEvent -LogName Microsoft-Windows-TaskScheduler/Operational -MaxEvents 30— task history (enable first)
ReferenceWhy it matters1 section · depth on demand
Trigger types
| Trigger | Example |
|---|---|
| Time | Once, daily, weekly, monthly |
| At startup | Before user logon |
| At logon | Any or specific user |
| On idle | After idle period |
| On event | Specific event ID in a log |
| On workstation lock/unlock, session connect | User session events |
Event triggers are useful for reacting to failures (e.g. run a script on event 7034 service crash).
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
Scheduled task triggers:
| Trigger | Example |
|---|---|
| Time / daily / weekly | Nightly maintenance |
| At startup | Service-like jobs (runs before logon) |
| At logon | Per-user scripts |
| On idle | Defragmentation-style work |
| On an event | React to event ID (e.g. 4625 failed logons) |
| On session connect/lock | RDS scenarios |
$t = New-ScheduledTaskTrigger -Daily -At 02:00
$t2 = New-ScheduledTaskTrigger -AtStartup
Register-ScheduledTask -TaskName Cleanup -Trigger $t,$t2 -Action (New-ScheduledTaskAction -Execute powershell.exe -Argument '-NoProfile -File C:\Scripts\cleanup.ps1') -User SYSTEM -RunLevel Highest
ReferenceConfiguration & state1 section · depth on demand
Commands
$t = New-ScheduledTaskTrigger -Daily -At 02:00 -RandomDelay (New-TimeSpan -Minutes 30)
$a = New-ScheduledTaskAction -Execute powershell.exe -Argument '-NoProfile -File C:\Scripts\job.ps1'
Register-ScheduledTask -TaskName NightlyJob -Trigger $t -Action $a -User SYSTEM -RunLevel Highest
Documented example, not captured output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Task Scheduler → Triggers. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page · confidence 94%