Pcornel
Browse topics
Options
Recent
Favorites
Windows · Technical reference

Actions

Direct answer

Task actions define what a scheduled task does, usually start a program with arguments and a working directory, such as powershell.exe -File script.ps1. A task can run several actions in order.

When to use this

Use this when a scheduled task's program or script doesn't run correctly.

First 30 seconds

1. (Get-ScheduledTask <name>).Actions — Execute, Arguments, WorkingDirectory.

2. Full paths; quote paths with spaces.

3. PowerShell: powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\x.ps1".

4. Exit code appears as LastTaskResult.

5. Log output to a file.

Operational verification

action starts program with arguments in the start-in folder → exits with a code

Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Common mistakes
  • PowerShell scripts run without -NoProfile -ExecutionPolicy Bypass -File, failing on policy or profiles.
  • Missing "Start in" folder for scripts with relative paths.
  • Task running as SYSTEM accessing network shares (uses the computer account).
  • Output not logged, so failures are invisible — redirect to a log file or use Start-Transcript.
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 a scheduled task's program or script doesn't run correctly.
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 Checks Verify boundary
Get-ScheduledTaskInfo -TaskName NightlyJob | Select LastRunTime,LastTaskResult,NextRunTime
schtasks /query /tn NightlyJob /v /fo list

LastTaskResult 0 = success, 0x41301 = running, 0x1 = script error. Enable task history in Task Scheduler for event details (Microsoft-Windows-TaskScheduler/Operational).

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
  • Use full paths for programs and scripts.
  • Arguments go in their own field.
  • Set the working directory ('Start in').
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

Writing actions

  • Use full paths to programs and scripts; the working directory defaults to C:\Windows\System32.
  • PowerShell: powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\scripts\job.ps1 (signed scripts preferred).
  • Exit codes appear as Last Run Result (0x0 = success, 0x1 = general failure in the script).
  • Run as a dedicated account or gMSA with least privilege, not a personal admin account.
ReferenceImportant terms & boundaries1 section · depth on demand

In depth

Task actions run programs ("Start a program"; e-mail and message actions are deprecated). Run PowerShell scripts with explicit arguments:

program: C:\Program Files\PowerShell\7\pwsh.exe
arguments: -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "C:\Scripts\report.ps1" -Days 7
start in: C:\Scripts

Set "Start in" so relative paths work, log output from the script itself (tasks have no console), and return non-zero exit codes on failure so Last Run Result reflects errors.

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 → Actions. 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?