Use this when scheduling automation with Windows Task Scheduler.
Windows Task Scheduler
Windows Task Scheduler runs programs and scripts on schedules or events, configured in taskschd.msc, schtasks or Register-ScheduledTask, with history in the TaskScheduler Operational log.
1. Task Scheduler for Windows jobs.
2. Run as gMSA.
3. Configure "do not start new instance" to avoid overlap.
4. History enabled.
5. Check result codes.
trigger → task → action
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Get-ScheduledTaskInfo -TaskName BackupVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as DST/timezone drift, duplicate firing, missed triggers, scheduler downtime, dependency race, long-running overlap and successful trigger without successful target work, choosing the cases most relevant to task path/name identity, trigger timezone, principal/logon type, actions/conditions/settings, last result and proving the target action actually succeeded.
Step 2 Example Narrow the fault
$a = New-ScheduledTaskAction -Execute 'pwsh.exe' -Argument '-File C:\Scripts\backup.ps1'
$t = New-ScheduledTaskTrigger -Daily -At 2am
Register-ScheduledTask -TaskName Backup -Action $a -Trigger $t -User 'SYSTEM'
Get-ScheduledTaskInfo -TaskName Backup
Step 3 Common mistakes Narrow the fault
- Tasks running as a user whose password changes.
- No logging from the script.
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.
- Use taskschd.msc, schtasks or Register-ScheduledTask.
- Account and conditions decide whether it runs.
- History is in the TaskScheduler Operational log.
Get-ScheduledTask -TaskPath \<folder>\— tasksGet-ScheduledTaskInfo <n>— last run/resultschtasks /query /v /fo list /tn <n>— details
ReferenceWhy it matters1 section · depth on demand
What it is
Windows Task Scheduler runs programs and scripts on schedules or events, under a chosen account.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Windows Task Scheduler runs programs and scripts on schedules or triggers (logon, startup, event log entries). It is the native scheduler for Windows automation and can be configured by GUI, schtasks.exe or PowerShell.
$action = New-ScheduledTaskAction -Execute 'pwsh.exe' -Argument '-NoProfile -File C:\Scripts\backup.ps1'
$trigger = New-ScheduledTaskTrigger -Daily -At 02:30
$set = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hours 1) -StartWhenAvailable
Register-ScheduledTask -TaskName 'Config backup' -Action $action -Trigger $trigger -Settings $set `
-User 'CORP\svc_backup$' -LogonType Password # gMSA
Get-ScheduledTaskInfo 'Config backup' | Select-Object LastRunTime, LastTaskResult
LastTaskResult 0 means success. Run tasks as gMSAs or dedicated service accounts, and enable task history for troubleshooting.
Mechanics
The linked authority for bounded mechanics is Microsoft Learn — Task Scheduler; documentation support is separate from observed lab/production Evidence.
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 Scheduling > Windows Task Scheduler. 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%Deep reference
Healthy vs suspicious evidence
Output interpretation
For task path/name identity, trigger timezone, principal/logon type, actions/conditions/settings, last result and proving the target action actually succeeded, prefer typed fields and stable IDs over human presentation text.