Use PowerShell to manage Scheduled Tasks in Windows
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.
- Open a command prompt window. You can do that with a tap on the Windows-key, typing Powershell.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.
- Type Get-ScheduledTask
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.
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.
I would suggest checking out sysinternals autorun. It will show you “all” programs that autostart and you can see if they are signed and there is an excellent option to check hashes against virustotal.com
I agree, it is an invaluable tool which Microsoft should have integrated into Windows a long time ago. I do think however that is is good to have several aces up your sleeve at all time, and PowerShell is a mighty powerful weapon that is hardly ever talked about it seems in mainstream media.
“You can do that with a tap on the Windows-key, typing cmd.exe” typo maybe? That’s not the Powershell shortcut.
Anyway, thanks Martin.
Yeah, it is easier to open PowerShell directly of course ;)
The more it goes, and the more articles I see like yours… the more I realize that I had better pick up a couple of good Powershell books, sooner, rather than later, since I still work Windows, and many of those I support, likewise work entirely within a Windows ecosystem.
Whatever happened to the more innocent days of batch file scripts!?
Wish this would’ve work on Windows 7 becasue it don’t and really wanted to get to know PowerShell sad next time I guess when I decided to move on to Windows 10.