Use this when a Windows task should run automatically, or when a scheduled task doesn't run or fails.
Task Scheduler
Task Scheduler runs programs or scripts automatically on triggers such as a schedule, startup, logon or event, with conditions and settings controlling when and as which account they run.
1. Get-ScheduledTaskInfo <name> — LastRunTime, LastTaskResult (0 = success)?
2. Trigger correct and enabled?
3. Action: program path and arguments, start-in folder.
4. Run as: account, "Run whether user is logged on or not", highest privileges?
5. History in TaskScheduler/Operational.
trigger fires → conditions met → task starts under its account → action runs → result recorded
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
schtasksPrimary Commands
Configuration and operational commands for this Topic.
Subtopics
Go one level deeper into this subject.
Scheduled tasks run actions automatically when triggered, as a chosen user or SYSTEM.
Subtopic TriggersTask 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.
Subtopic ActionsTask actions define what a scheduled task does, usually start a program with arguments and a working directory, such as powershell.exe -File script.ps1.
Subtopic ConditionsTask conditions add requirements beyond the trigger, such as only run when idle, on AC power or with a network connection.
Subtopic Task Scheduler LibraryThe Task Scheduler Library is the folder tree of all scheduled tasks, including Microsoft's built-in ones under \Microsoft\Windows.
Subtopic Scheduled Task TroubleshootingTroubleshoot scheduled tasks via Last Run Result codes, the Task Scheduler Operational log, the account and 'Run whether user is logged on or not' setting, working directory, conditions and script execution policy.
- Last Run Result code explains failures.
- Account and 'run whether logged on' matter.
- Conditions can silently skip runs.
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)
ReferenceImportant terms & boundaries1 section · depth on demand
How it works
Task Scheduler (service Schedule) runs programs and scripts on triggers such as time, logon, startup or events, under a chosen account. Tasks are stored as XML under C:\Windows\System32\Tasks and logged in Microsoft-Windows-TaskScheduler/Operational when history is enabled.
ReferenceConfiguration & state1 section · depth on demand
Commands
Get-ScheduledTask | Where State -ne Disabled
Get-ScheduledTaskInfo -TaskName "Backup" # last run time and result
schtasks /query /tn "Backup" /v /fo list
$a = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File C:\scripts\job.ps1"
$t = New-ScheduledTaskTrigger -Daily -At 2am
Register-ScheduledTask -TaskName "Job" -Action $a -Trigger $t -User "SYSTEM"
Documented example, not captured output. History is in the Microsoft-Windows-TaskScheduler/Operational log (enable it first).
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. 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%