Examining Scheduled Tasks

by Jun 19, 2013

There is a COM interface that you can use to select and dump any scheduled task definition. Just make sure you are running PowerShell with full Administrator privileges.

This example dumps all tasks in Task Scheduler Library\Microsoft\Windows\DiskDiagnostic:

$service = New-Object -ComObject Schedule.Service

$folder = $service.GetFolder('\Microsoft\Windows\DiskDiagnostic')
$tasks = $folder.GetTasks(1) 

# Number of tasks in that container:
$count = $tasks.Count
"There are $count tasks"

# Task statistics:
$tasks | Select-Object -Property Name, Enabled, LastRunTime, LastTaskResult, NextRunTime

You can easily find out how many tasks are defined in a given container, and whether tasks are enabled, their last and their next runtime.

Twitter This Tip! ReTweet this Tip!