PowerShell Genie

ScheduledTasks module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Inspect task definitions, triggers and principals with Get-ScheduledTask, then verify execution history instead of assuming registration means success.

Getting it

Present on Windows 8 and Windows Server 2012 onward with nothing to install.

Examples

1PS> Get-ScheduledTask -TaskPath "\"
Show reference output
1 TaskPath TaskName State LastTaskResult
2 ------------------- ----------- -------- --------------
3 \ Backup Ready 0
4 \Microsoft\Windows\ Maintenance Disabled 0
1PS> Get-ScheduledTaskInfo -TaskName "Backup-Server"
Show reference output
1 TaskPath TaskName State LastTaskResult
2 ------------------- ----------- -------- --------------
3 \ Backup Ready 0
4 \Microsoft\Windows\ Maintenance Disabled 0

What it is for

Use it when scheduled work needs an audit, or when a task has to be created identically across a fleet of servers. Get-ScheduledTaskInfo is where last run time and last result live, and that is what failure reporting actually needs.

Typical tasks

  • Find tasks whose last result was not zero
  • List tasks under a specific folder path
  • Read last run and next run times
  • Register a task from action and trigger objects
  • Change the account a task runs under
  • Disable a task without deleting it

Check the installed version

1PS> Get-Module -ListAvailable ScheduledTasks | Select-Object Name, Version, Path
2PS> Get-Command -Module ScheduledTasks

Compare the module path and version with the session used by your scheduled task or automation account. Use it when scheduled work needs an audit, or when a task has to be created identically across a fleet of servers. Get-ScheduledTaskInfo is where last run time and last result live, and that is what failure reporting actually needs.

Primary documentation

Windows services and processes documentation

Continue
Genie guideScheduledTasks module: setup and commands

Inspect task definitions, triggers and principals with Get-ScheduledTask, then verify execution history instead of assuming registration means success.