How to Schedule A Task to Run A PowerShell Script Using Task Scheduler

Welcome to an article on How to schedule a task to run a PowerShell script using Task Scheduler on our Windows Server.

In our project, we went through many scenarios where we did not have time to create a timer job for some basic functions but we needed a schedule to happen without creating timer jobs. We can achieve the same by using PowerShell script and schedule it using Task Scheduler. It will save your time and effort in creating a timer job as building a PowerShell script is easy. It will work the same way as you expect from a timer job.


How? Let’s see it.

  1. Go to Window’s Start Button.

  2. Search for a Task Scheduler.

  3. Once you find it, click on it.

  4. You will see the screen below.

    Task Scheduler

  5. On the right corner, Click on Create Task.

    Create

  6. You will see the following dialog box that will pop up.

    dialog box

    Configure the General Tab with the following details.

    • Name - Provide a name for the job.

    • Description - Description states why you are running this job.

    • User - You can state under whose user ID, this should run. You should always select the admin ID.

    • You can choose, if you want to run the job with highest privileges.

  7. Once done, click on Triggers Tab.

    Triggers

    • Click on New Button.

      New

    • You can configure whether you want to run this schedule once or daily or weekly or monthly according to your scenario.

  8. One configured, Click on the Actions Tab.

    Actions

    • Click on the New button to configure the action.

      New

    Configuration

    This is the most important part where most of the users go wrong.

    • Action - As action, select “Start a program”.
    • Program/script - Here type in “powershell”.
    • Add arguments (optional) - It is not optional. Provide a path to your script as the following
      -file "C:\MyScriptSchedule\Schedule.ps1".

  9. Once configured, you can set any Condition if you have to run this scheduled job.

    Condition

  10. On the Settings tab, you can see; if you need to do any modification. I took the default settings.

    Settings

  11. Click OK.

  12. It will ask the password of the admin ID, you are running schedule with.

  13. Sit and relax. Your schedule will run as expected according to your schedule without any issue.
In this article, we saw how to schedule a task to run a PowerShell script using Task Scheduler.