rss logo

How to run a PowerShell script from the Windows Task Scheduler

Microsoft logo PowerShell logo

For several years now, PowerShell has been the go-to scripting language for Windows. Knowing how to run a PowerShell script through the Windows Task Scheduler can greatly enhance your ability to automate tasks. In this guide, I'll walk you through the process of scheduling and running a PowerShell script using the Windows Task Scheduler.

Create a PowerShell script

  • For our example: c:\Path\PScript.ps1.
Path of the PowerShell script displayed in File Explorer

Create a task

  • Open Windows Task Scheduler:
Opening the Task Scheduler with the Run dialog using taskschd.msc
  • Right-click on the Task Scheduler Library and select Create Task… to create a new task:
Creating a new task in the Task Scheduler by selecting Create Task
  • Give the task a name (e.g. My_Task), select the user under which the task will run (e.g. NT AUTORITY\SYSTEM) and check the box to hide the task:
Configuring a task in Task Scheduler with NT AUTHORITY System, highest privileges, and hidden options Selecting the SYSTEM account in the Windows Task Scheduler for task configuration
  • In the Actions tab, click on New…:
Adding a new action in the Windows Task Scheduler task configuration
  • Set the New Action as follows:
    • Program/script: powershell.exe
    • Add arguments: -Noninteractive -Noprofile -ExecutionPolicy bypass -Command "& 'C:\Path\PScript.ps1'"
Configuring a PowerShell script action in the Windows Task Scheduler
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contact :

contact mail address