Scheduled Tasks

Keeping on the theme of Scheduled Tasks I wanted to dig into the tasks that exist on my system.  I did a fresh install of Windows 7 in August and haven’t created any scheduled tasks – so what I see should be close to the system defaults.  This machine isn’t in a domain.

I can load the task scheduler functions

PS> Import-Module TaskScheduler
PS> get-command -Module TaskScheduler

CommandType     Name
-----------     ----
Function        Add-TaskAction
Function        Add-TaskTrigger
Function        Connect-ToTaskScheduler
Function        Get-RunningTask
Function        Get-ScheduledTask
Function        New-Task
Function        Register-ScheduledTask
Function        Remove-Task
Function        Start-Task
Function        Stop-Task

I can see the tasks that are running

PS> Get-RunningTask

Name          : SystemSoundsService
InstanceGuid  : {9E499B76-8A4E-4215-B043-619B0403D8F6}
Path          : \Microsoft\Windows\Multimedia\SystemSoundsService
State         : 4
CurrentAction : Microsoft PlaySoundService Class
EnginePID     : 2456

in this case the definition is empty so I can’t see exactly what it is doing though the path and name give a strong hint its related to the sound system.

Scheduled tasks are arranged in a folder hierarchy.   If you want to see the full list use

Get-ScheduledTask –Recurse

we see a large number of jobs that are either disabled, ready or running.

If you compare the list with the Task scheduler GUI tool you will see some jobs are missing.  These can be viewed by using the hidden switch

Get-ScheduledTask -Recurse -Hidden | select path, name

It is also possible to directly supply a folder and view the jobs in there.

Looking at the total job population

PS> Get-ScheduledTask -Recurse -Hidden | group status

Count Name                     
----- ----                    
   57 Ready                     
   20 Disabled                  
    2 Running                   
    1 Queued
                    

The Ready jobs look interesting

Get-ScheduledTask -recurse -hidden | where {$_.status -eq "Ready" -and $_.LastRunTime -gt $((get-date).AddMonths(-1))} | sort LastRunTime -Descending

will show everything run in the last month that is ready to run again.  Surprising just how many back ground tasks occur.

Next time we’ll look at setting up a task to run when we login.

Published Fri, Nov 13 2009 15:42 by RichardSiddaway

Leave a Comment

(required) 
(required) 
(optional)
(required)