Powershell

How to Run PowerShell Script Using Task Scheduler?

Microsoft Task Scheduler in Windows is used to schedule or launch an application or a script at a specific time. It will only run a script when certain conditions are met. A script is a text file that consists of PowerShell commands. The “Task Scheduler” app can run repetitive tasks without putting in extra effort. It is helpful for system admins as it reduces effort, saves time, and executes tasks at a specific time.

This write-up will demonstrate a procedure to schedule a script.

How to Run PowerShell Script Using Task Scheduler?

To schedule a PowerShell script in the “Task Scheduler” app, follow the given stepwise instructions.

Step 1: Launch Task Scheduler App

First, navigate to the “Startup” menu, search “Task Scheduler” and then open it:

Step 2: Create a New Task

Click on the “Action” menu button and select “Create Task…” from the drop-down menu:

Step 3: Enter Name and a Description

Add the task name and an optional description, then hit the “OK” button:

Step 4: Set the Trigger

Move to the “Triggers” tab and click on the “New…” button to set the trigger:

Select frequency, such as “One time”, “Daily”, “Weekly”, or “Monthly” as per the user’s choice. Then, select the time and hit the “OK” button to finish setting the trigger:

Step 5: Configure the Action

Switch to the “Actions” tab and trigger the “New…” button:

Step 6: Select the PowerShell Executable

Select “Start a program” from the “Action” section and click on the “Browse…” button to select “PowerShell” program:

Navigate to this address “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe” or copy/paste it to the “Program/script” input section. When found the “PowerShell” application, click on the “Open” button to launch it:

Step 7: Add the Script Path as an Argument

Now, add the script address in the “Add arguments” input section and hit the “OK” button to schedule the PowerShell script to run at the specific provided time:

Step 8: Review and Confirm

Move back to the main window of the “Task Scheduler”, navigate to the “Task Scheduler Library” section and there you can see the highlighted scheduled PowerShell script:

That’s it! You have learned to schedule a PowerShell script.

Conclusion

To execute a script in PowerShell by utilizing the “Task Scheduler” app, first, launch the stated app. Then, specify the name and description of the task to be scheduled. After that, create a trigger, such as specifying the time and date. Next, provide the PowerShell script address. This post has elaborated on the procedure to schedule a PowerShell script.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.