Pcornel
Browse topics
Options
Recent
Favorites
Windows · Technical reference

Scheduled Tasks

Direct answer

Scheduled tasks run actions automatically when triggered, as a chosen user or SYSTEM. Create them in Task Scheduler, with schtasks /create or Register-ScheduledTask.

When to use this

Use this when creating scheduled tasks that must run reliably as the right account with logging.

First 30 seconds

1. List: Get-ScheduledTask | ? TaskPath -notlike '\Microsoft*'.

2. State Ready/Disabled/Running?

3. Create: Register-ScheduledTask with action, trigger and principal.

4. Run now: Start-ScheduledTask <name>.

5. Check result.

Operational verification

task registered → triggers, conditions, settings, principal, actions → runs

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Windows execution, automation and observability
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformWindows execution, automation and observability
Scope / prerequisiteUse this when creating scheduled tasks that must run reliably as the right account with logging.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Common mistakes Narrow the fault
  • Tasks running as users who later leave or change passwords.
  • Tasks that run at logon on servers nobody logs on to.
Evidence references

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.

observation · 1
Key points
  • Choose the account a task runs as.
  • Triggers decide when it runs.
  • Log the task's own output.
Key checks
  • Get-ScheduledTask -TaskName <name> | fl * — task definition
  • Get-ScheduledTaskInfo -TaskName <name> — last run time and result
  • schtasks /query /tn <name> /v /fo list — details in CMD
  • Get-WinEvent -LogName Microsoft-Windows-TaskScheduler/Operational -MaxEvents 30 — task history (enable first)
ReferenceWhy it matters1 section · depth on demand

How it works

A scheduled task has three parts: one or more triggers (time, logon, startup, event ID, idle), actions (usually a program with arguments) and settings (run as which account, whether the user must be logged on, retry and stop rules). The Task Scheduler service (Schedule) runs it and records each run in Microsoft-Windows-TaskScheduler/Operational (enable history first). Exit code 0x0 means success; 0x41301 means still running.

ReferenceImportant terms & boundaries2 sections · depth on demand

In depth

Read a task's last result

PS C:\> Get-ScheduledTask -TaskName NightlyExport | Get-ScheduledTaskInfo
LastRunTime        : 27-11-2026 02:00:01
LastTaskResult     : 2147942402
NextRunTime        : 28-11-2026 02:00:00
NumberOfMissedRuns : 0
PS C:\> '{0:X}' -f 2147942402
80070002
LastTaskResultMeaning
0Success
0x41301 (267009)Task is currently running
0x41303Task has not yet run
0x80070002File not found — wrong path or working directory
0x80070005Access denied — account lacks rights or "Log on as batch job"
0x800710E0Operator or administrator refused the request — often "Run only when user is logged on" with nobody logged on
Program's own exit codeWhatever the script returned (for example 1)

Create a task that behaves like a service job

$a = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-NoProfile -ExecutionPolicy Bypass -File D:\Jobs\export.ps1' -WorkingDirectory 'D:\Jobs'
$t = New-ScheduledTaskTrigger -Daily -At 02:00
$s = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hours 2) -RestartCount 2 -RestartInterval (New-TimeSpan -Minutes 10) -StartWhenAvailable
Register-ScheduledTask -TaskName NightlyExport -Action $a -Trigger $t -Settings $s -User 'CORP\gmsa-jobs$' -LogonType Password

A group managed service account (gmsa-jobs$) avoids stored passwords that expire. Set the working directory — scripts using relative paths otherwise run in C:\Windows\System32.

History and auditing

Task history is off by default: enable it (Task Scheduler → Enable All Tasks History, or wevtutil set-log Microsoft-Windows-TaskScheduler/Operational /enabled:true). Event 100 (started), 102 (completed), 201 (action completed with return code) and 103/101 (failed) then show the run.

Security review

Tasks run with stored credentials or as SYSTEM are a persistence technique for attackers. schtasks /query /fo LIST /v exports all tasks with their run-as account and actions for review.

*The scheduled task timestamps and result codes above are illustrative examples, not captured from a lab or production system.*

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docWindows execution, automation and observability current

Authoritative/upstream documentation reviewed for bounded claims in Task Scheduler → Scheduled Tasks. 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%
Confirmation

Confirm action

Continue?