Previously, I’ve shown you how to open a webpage or URL on schedule using task scheduler. Recently, one of the windowsloop readers emailed me asking how to run PowerShell script. The thing is since the task scheduler is very versatile and can launch almost any launch almost anything, you can actually run PowerShell script on schedule and it is quite useful.
For instance, I have a custom PowerShell script that checks for all available Windows updates and lists their KB (knowledge base) number, name, and download size. Generally, I used to manually execute the script as and when needed. i.e, almost daily. However, by scheduling the PowerShell script to launch at system log on, I don’t have to manually execute the script. Which simply means that it is one less thing I need to do.
So, without ado, let me show you how to launch a PowerShell script on schedule using task scheduler.
Note: I assume that you already have a PowerShell script to schedule and set a proper execution policy to execute PowerShell scripts.
Schedule PowerShell Script with Task Scheduler
1. First, search for the task scheduler in the start menu and open it. You can also use the
taskschd.msc command in the run dialog box to open the task scheduler.
2. After opening the task scheduler, click on the “Create Basic Task” option appearing under Task Scheduler Library section on the right panel.
3. The above action will open the scheduled task creation wizard. Here, type in the proper name and description and click on the “Next” button. A good name and description help you easily identify the task in the list.
4. Here, select when you’d like to start the script. In my case, I want the script to start as soon as I log into the system. So, I selected the “When I log on” option. Once you select the appropriate option, hit the “Next” button.
5. To run PowerShell scripts, we need to use the PowerShell program. So, select “Start a program” option and click on the “Next” button.
6. In the “Program/Script” field, enter the PowerShell executable path. You can use the below path as the PowerShell executable path. In the “Add arguments” filed, type the PowerShell script path. For instance, I’ve stored my PowerShell script in the root of D drive. So, I’ve entered “D:\hello_world.ps1” in the arguments field. Click on the “Next” button to continue.
7. Task scheduler will now show a preview of all your settings, go through them and once you are satisfied, click on the “Finish” button to save the task.
8. That is all. You’ve created a scheduled task to launch a PowerShell script. Just to test if the task is working as it should, find the task in the list, right-click on it and select the “Run” option.
9. If everything goes right, you should see the PowerShell script running. In my case, I’m running a simple hello world script that waits for user input to close. As you can see, it runs perfectly fine.
That is all. It is that simple to schedule a PowerShell script in Windows 10.