Home » How To » How To Run a PowerShell Script on Schedule With Task Scheduler

How to Run PowerShell Script on Schedule in Windows

Have a script that needs to run at a specific time? You can use the Task Scheduler program in Windows to launch your PowerShell script on a schedule. For example, I check for new Windows updates daily using a PowerShell script. Rather than executing it manually, I created a scheduled task that runs the script automatically when I log on.

In this article, I will take you step-by-step on scheduling a PowerShell script with Task Scheduler to run automatically at a specific time or event. Additionally, I’ll show you how to configure advanced options such as launching the script with admin rights and adding a delay to the launch schedule. Let’s get started.

Related: How to run a PowerShell script on startup

Before You Begin

Schedule PowerShell Script with Task Scheduler

Here are the steps to schedule a PowerShell script with Task Scheduler in Windows 10 and 11.

Simple Steps:

  1. Open the Task Scheduler from the Start menu.
  2. Click the “Create Basic Task” option.
  3. Name the new scheduled task and click “Next.”
  4. Choose a launch trigger and click “Next.” For example, I chose “When I log on.”
  5. Choose the “Start a program” option and click “Next.”
  6. Enter “powershell.exe” in the “Program/Script” field.
  7. Enter the script path in the “Add arguments” field.
  8. Click “Next.”
  9. Click “Finish.”
  10. With that, you have scheduled a PowerShell script.

Detailed Steps:

First, press the Start button, search for the Task Scheduler, and click Open. Alternatively, you can also use the run command “taskschd.msc.”

    Open task scheduler from start menu

    Click the “Create Basic Task” option in the right sidebar of the Task Scheduler window. This option lets you create a scheduled task via a simple setup wizard.

      Schedule powershell script 01

      Enter the descriptive name for the task in the “Name” field and a short note in the “Description” field. Once done, click on the “Next” button. A good name and description will make it easy to identify your scheduled task from others.

        Schedule powershell script 02

        Now, select the trigger of your choice. For example, to launch the script after logging in, select “When I log on.” Select Daily, Weekly, and Monthly to run the script at a specific time or date.

          Schedule powershell script 03

          Select the “Start a program” option and click “Next.”

            Schedule powershell script 04

            Enter “powershell.exe” in the “Program/Script” field. In the “Add Arguments” field, enter the full path of the PowerShell script between quotes. For example, "D:\hello_world.ps1" Click “Next.”

            add PowerShell argument and script path

            Click the “Finish” button and you are done creating the scheduled task to run a PowerShell script.

              Schedule powershell script 06

              That’s it. With that, you’ve created the scheduled task that runs your PowerShell script on schedule.

              Additional Configurations (Optional)

              Launch the scheduled task with admin rights:

              If you want your PowerShell script to run with admin rights when launched using Task Scheduler, you must run the scheduled task as an administrator. Here’s how to configure it.

              1. Open Task Scheduler.

              2. Find and right-click on the scheduled task.

              3. Select “Properties.”

              open task properties

              4. Go to the “General” tab.

              5. Select the “Run with highest privileges” checkbox.

              6. Click “OK.”

              select run with highest previlages checkbox

              7. If prompted for an admin password, type it and click “OK.”

              Launch the scheduled task with delay:

              If you are launching the script at system startup, you might want to consider running the scheduled task with some delay, as long as it’s not a time or event sensitive script. That way, you can make sure your system doesn’t slow down due to too many startup tasks. Here’s how to do it.

              1. Open Task Scheduler.

              2. Find and right-click on the scheduled task.

              3. Select “Properties.”

              open task properties

              4. Go to the “Triggers” tab.

              5. Select the trigger and click “Edit.”

              edit trigger

              6. Select the “Delay task for” checkbox and choose a delay time from the dropdown menu.

              7. Click “OK.”

              delay scheduled task

              Verify the Scheduled Task

              Once you’ve created the scheduled task, it’s best practice to verify the script runs. To verify, find the task in the list, right-click on it, and select the “Run” option.

              Schedule powershell script 07

              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.

              Schedule powershell script 08

              If the script doesn’t launch, verify that you’ve added your script path correctly.

              Wrapping Up — Scheduling PowerShell Scripts

              As you can see, it is pretty easy to use the built-in Task Scheduler program to schedule PowerShell scripts when you want to run them automatically at a specific time or event. Before configuring the task, make sure you have set the appropriate execution policy. Moreover, follow the additional configurations such as assigning admin rights and adding delay to non-essential scripts as needed to make the scheduled task run efficiently.

              If you have questions or need help, comment below. I will help.

              Leave a Comment

              Your email address will not be published. Required fields are marked *

              Scroll to Top