Have a script that needs to run at a specific time? You can use the task scheduler to launch the PowerShell script on a schedule.
Previously, I’ve shown you how to open a webpage or URL on schedule using the Task Scheduler. One of the windowsloop readers recently emailed me asking how to run the PowerShell script on a schedule. Since the task scheduler is very versatile and can launch almost anything, you can run the PowerShell script on schedule with the Task Scheduler. What’s more, it is pretty helpful and straightforward too.
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 execute the script as and when needed manually. i.e., almost daily. However, I don’t have to run the script manually by scheduling the PowerShell script to launch at the system log on. That is one less thing I need to do every day.
So, let me show you how to launch a PowerShell script on schedule using the Task Scheduler.
Note: I assume that you already have a PowerShell script to schedule and set an acceptable execution policy to execute PowerShell scripts. The steps shown will work in Windows 10 and 11.
Schedule PowerShell Script with Task Scheduler
Here are the steps to schedule a PowerShell script with Task Scheduler in Windows 10 and 11.
- Open the Task Scheduler from the Start menu.
- Click the “Create Basic Task” option.
- Name the new scheduled task and click “Next.”
- Choose “When I log on” and click “Next.”
- Choose the “Start a program” option and click “Next.”
- Type the below path in the “Program/Script field.”
- Type the script path in the “Add arguments” field.
- Click “Next.”
- Click “Finish.”
- With that, you have scheduled a PowerShell script.
Same steps with a bit more detail and screenshots:
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 the Task Scheduler Library section on the right panel.
3. The above action will open the scheduled task creation wizard. Type in a proper name and description and click on the “Next” button. A good name and description will help you quickly 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 begin as soon as I log into the system. So, I selected the “When I log on” option. Once you choose the appropriate option, hit the “Next” button.
5. To run PowerShell scripts, we need to use the PowerShell program. So, select the “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” field, type the PowerShell script path. For instance, I’ve stored my PowerShell script in the root of the D drive. So, I’ve entered “D:\hello_world.ps1” in the arguments field. Click 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. 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.