Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Scheduled Jobs · PowerShell Automation

Direct answer

PowerShell scheduled jobs (Register-ScheduledJob) or scheduled tasks (Register-ScheduledTask) run scripts on a schedule; use a service account or gMSA and log output to a file.

When to use this

Use this when scheduling PowerShell scripts.

First 30 seconds

1. Scheduled jobs/tasks run scripts on a schedule.

2. Prefer Task Scheduler with gMSA.

3. Log output.

4. Check LastTaskResult.

5. Avoid storing passwords in tasks.

Operational verification

schedule → task → script → result code

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Windows PowerShell 5.1
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 PowerShell 5.1 · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when scheduling PowerShell scripts.
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.

3 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 Verification path Verify boundary

Inspect definitions with Get-ScheduledJob, correlate them with Task Scheduler state, and review job instances/output after a run. Trigger a controlled test under the actual scheduled identity and verify target state after execution. Capture both scheduler history and PowerShell job output because either layer can fail independently.

Step 2 Common mistakes Narrow the fault
  • Scheduled jobs running as users who leave.
Step 3 Where it fails Narrow the fault

Do not treat Scheduled Jobs as a cross-platform/current-PowerShell primitive. The scheduling service, Windows PowerShell 5.1 engine, job repository and target operation are distinct boundaries. Migration requires preserving identity, trigger semantics, credentials and output/retention behavior rather than only copying command text.

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 scheduled tasks for PowerShell scripts.
  • Run as a service account or gMSA.
  • Log output to a file.
Key checks
  • Get-ScheduledJob — PS scheduled jobs (5.1)
  • Get-ScheduledTask -TaskPath \Custom\ — Task Scheduler tasks
  • Get-ScheduledTaskInfo -TaskName <n> — last result
ReferenceWhy it matters1 section · depth on demand

In depth

PowerShell scheduled jobs and Windows scheduled tasks run scripts automatically. Scheduled jobs (Register-ScheduledJob, Windows PowerShell 5.1) store results as job objects; for PowerShell 7 and general use, scheduled tasks are the standard.

$a = New-ScheduledTaskAction -Execute 'pwsh.exe' -Argument '-NoProfile -NonInteractive -File C:\Automation\Sync-Netbox.ps1'
$t = New-ScheduledTaskTrigger -Once -At (Get-Date).Date.AddHours(1) -RepetitionInterval (New-TimeSpan -Minutes 30)
$p = New-ScheduledTaskPrincipal -UserId 'CORP\gmsa-netsync$' -LogonType Password
Register-ScheduledTask -TaskName 'NetBox sync' -Action $a -Trigger $t -Principal $p

Write logs to a file or the event log from the script itself (Start-Transcript or a logging function), since scheduled tasks capture no console output, and exit with meaningful codes so LastTaskResult reflects failures.

ReferenceImportant terms & boundaries1 section · depth on demand

PowerShell mechanics

Windows PowerShell Scheduled Jobs combine the PSScheduledJob module with Windows Task Scheduler: a scheduled-job definition persists trigger/options/credential metadata, Task Scheduler starts the work, and completed instances are represented as PowerShell jobs with stored results. The feature is a Windows PowerShell 5.1 compatibility surface and is not available as a compatible feature in PowerShell 6+.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
ReferenceConfiguration & state1 section · depth on demand

Authoring and lifecycle

Use Scheduled Jobs only when Windows PowerShell 5.1 compatibility is an intentional requirement; for modern automation evaluate Task Scheduler directly or another scheduler/orchestrator. Record trigger, execution identity, working environment and output-retention settings. Do not assume an interactive user's profile, mapped drives or credentials exist in the scheduled context.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical examples

Configuration & expected output

Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.

Configuration example

Windows PowerShell 5.1 5.1Minimal authored PowerShell pattern for Scheduled Jobs

Assumptions: Review target identity, permissions and environment before mutation.

Register-ScheduledJob -Name DemoAudit -ScriptBlock { Get-Date } -Trigger (New-JobTrigger -Once -At (Get-Date).AddHours(1))
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 PowerShell 5.1 5.1

Microsoft Learn documentation reviewed for bounded PowerShell reference claims. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/powershell/module/psscheduledjob/about/about_scheduled_jobs?view=powershell-5.1 · confidence 94%
Embedded reference data

Quick lookup tables

Scheduled Jobs · PowerShell operational reference

Topic-specific PowerShell runtime identity, persistence, verification, output and failure-boundary lookup.

BoundaryScheduled Jobs reference
Runtime identityPowerShell edition/version + command/module source
Persistent intentScript/module/config prerequisites under source control
VerificationRead-only discovery → execution evidence → independent target read-back
Output contractStructured objects/streams before formatting
Failure boundarySeparate engine/binding from transport/API/native and target-state failures
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

A registered scheduled job can be enabled while its last run failed, and Task Scheduler can launch PowerShell successfully even when the script's business operation fails. Stored job output may differ from interactive formatting/environment. Correlate scheduler result codes, PowerShell errors and target-state read-back.

Confirmation

Confirm action

Continue?