Schedule PowerShell Tasks with Task Scheduler On Windows Server

In this blog post, I will show you how to schedule a PowerShell task with Windows Task Scheduler on Windows Server.

Task Scheduler

Running PowerShell tasks using task scheduler is very handy and can help running all kind of tasks and reports.

PowerShell works very well with Task Scheduler, and using this guide; you will be able to run scripts.

Create A Basic Task

To create a task, open task scheduler, right-click on the Task Scheduler Library and click on Create Basic Task…

From the Create Basic Task wizard fill in the details and click next.

Follow the wizard until you get to the Start a program screen.

When you get to the Start a program page, copy and paste the line below which will start PowerShell.exe

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

In the second line, Add arguments, copy paste the line below with the path to your script.

My script located in c:\scripts but it can be anywhere in the OS.

-NoLogo -NoProfile -ExecutionPolicy Bypass -File "c:\scripts\script.ps1"

Finish to save the task.

Run unattended

The most critical part in scheduling PowerShell scripts is to configure them to run regardless if we are logged in to the machine or not.

To configure the script to run, we need to set a user with local admin permission to run the script.

From the Task Scheduler main menu, right-click on the task and click properties.

Set the script to Run whether the user is logged on or not and also check the Run with highest privileges.

When you click, OK, you will be asked to provide a username and password.

Processing…
Success! You're on the list.