how to run a powershell script

Today in this article, we will see how to use Task Scheduler PowerShell with an example. We will schedule PowerShell Script using Windows Task Scheduler and automate PowerShell script execution.

Today in this article, we shall see below

There are many advantages of the Tasks scheduler, some of which are listed below,

  • Automate the Job/Task
  • Schedule tasks at a predefined schedule.
  • Schedule the task as per predefined priority.
  • Improves turnaround time by a running script at a convenient time. like nightly runs etc.

Let’s see in detail, how to schedule the PowerShell script through the Task scheduler.

Create Tasks Scheduler PowerShell Job

Open the Tasks Scheduler Windows -> search for Task scheduler or type taskschd.msc using Windows+R.

Tasks Scheduler PowerShell

Click on “Create Task”

schedule powershell script task scheduler

Define general configuration for Powershell Job

Define the below attributes,

  • Name – Define Application Name,
  • Description – Define a description of the task
  • Security options- Please select the appropriate Radio button. We shall select the option “Run whether the user is logged on or not”
    • Run with the highest privileges – To run the program with administrator privileges, its recommended to use this option
PowerShell Script using Windows Task Scheduler

Configure Powershell Tasks in the Task Scheduler

Click on the “Trigger” tab and define the configuration

In the next step, please click on the “Trigger” tab and click on “New” to create a new trigger.

You can define the condition of when to trigger the given task for example “On a schedule” or “On an event” or “on logon” or “on an event” etc.

Run Powershell script using task scheduler to

Configure Action in Task scheduler PowerShell

Click on the “Action” tab and define the configuration

In the next step, please click on the “Action” tab and click on “New” to create a new action.

Please specify the following parameters:

  • Action: Start a program
  • Program\script: Powershell
  • Add arguments (optional): -file [script path]

I have kept my script at the below path,

run powershell script using task scheduler

Schedule PowerShell Script using Windows Task Scheduler

Configure Condition in Task Scheduler

Click on the “Condition” tab and define the configuration

In the next step, please click on the “Condition” tab and select the appropriate options.

These additional conditions let you configure the task based on a specified selection. The task will not run if any conditions specified here are not met…

run powershell script using task schedulerTask scheduler PowerShell

Once configured, You should be able to run the PowerShell script using the task scheduler.

Reference :

Do you have any comments or ideas or any better suggestions to share?

Please sound off your comments below.

Happy Coding !!



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

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