Jump to content

Use PowerShell to manage Scheduled Tasks in Windows


Batu69

Recommended Posts

I check several locations regularly on Windows systems that I run including the Windows Task Manager to list running processes, the autostart entries, and also the scheduled tasks of the system.

I do that for a couple of reasons including security to make sure nothing slipped by and is running on the system that I consider malicious, spyware or unwanted in other ways, but also to debloat the system by disabling, blocking or removing programs from starting with the system or on schedule.

While it is possible to open the Task Scheduler using search, it does not provide you with a clean interface to go through the list of tasks quickly.

A program that I like to use for the task is Nirsoft's excellent Task Scheduler View which, as usual, is portable and highly efficient.

The PowerShell of Windows offers another quick option on Windows 8 and later. The command Get-ScheduledTask returns all or select scheduled tasks of the local computer.

  1. Open a command prompt window. You can do that with a tap on the Windows-key, typing cmd.exe, right-clicking on the result, selecting "run as administrator" and hitting enter. Note that the get-scheduledtask command does not require elevation while all management commands do.
  2. Type powershell to open the PowerShell prompt.
  3. Type Get-ScheduledTask

display-scheduled-tasks.jpg

The basic command lists all tasks of the local computer sorted by path. It only includes the task path, task name and state of the task which may be sufficient at times.

The name helps with the identification of the task while the state highlights whether it is enabled or disabled.

What makes this more powerful however are the parameters that you may add to the command to display additional details or filter tasks.

Here are some command examples that you may find useful:

  • Get-ScheduledTask -TaskName Google* returns all tasks that start with Google.
  • Get-ScheduledTask -TaskPath \ returns all tasks that are placed in the TaskPath root.

While it is useful to display scheduled tasks this way, you may also manage tasks using the PowerShell. Please note that you need elevated rights to run disable or enable tasks on a system. This means that you need to run PowerShell from an elevated command prompt.

The commands Disable-ScheduledTask and Enable-Scheduled-Task have been designed for that. As the names suggest, the first disables tasks you select while the second enables them.

If you run the commands directly, you need to specify task names or paths explicitly. There is a workaround for that though that you can use to enable or disable multiple tasks at once.

disable-scheduledtasks.jpg

Commands that you may find useful are:

  • Disable-ScheduledTask -taskname "Adobe Flash Player Updater" disables the task Adobe Flash Player Updater.
  • Enable-ScheduledTask -taskname "Adobe Flash Player Updater" enables the task Adobe Flash Player Updater.
  • Get-ScheduledTask -taskname Google* | Disable-ScheduledTask disables all tasks the get command returns (starting with Google),

Other task related commands of interest are start-scheduledtask, stop-scheduledtask and unregister-scheduledtask.

Source

Link to comment
Share on other sites


  • Replies 1
  • Views 1.2k
  • Created
  • Last Reply

or just do something like this...

SCHTASKS /query | findstr /B /I "YourTask" >nul && SCHTASKS /Change /TN "Path\YourTask" /Disable

;)

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...