Disable/Enable Scheduled tasks using Powershell and COMObject

While working on a project for a client where many of the Windows Systems are 2008R2 with PowerShell 3.0 or lower, there was a need to automate disabling scheduled tasks to ensure consistency across the XenApp/XenDesktop estate.

This is something that can be done easily in PowerShell 4.0+ using Get-scheduledTask cmdlet. But in PowerShall 3.0 and earlier, it gets a bit trickier.

Based on the script by Jaap Brasser where he enumerates all tasks subfolders, I have written a new code which can accept an array of schedule tasks names, along with a switch to enable/disable them.

How to use

  1. Add the below two functions in your PowerShell session on the system where the tasks should be disabled.
  2. Call the  Set-TaskStatus function and pass the status (Enabled, Disabled) and the tasks names (Array)


The output will be something like this


The Script


Disable/Enable Scheduled tasks using Powershell and COMObject
Tagged on:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: