Run PowerShell script from scheduled task

I have quite often seen the case where someone is setting up a PowerShell script to run as a scheduled task and they will create a wrapping .bat file to call the script. However, you can quite easily call a PowerShell script directly from a scheduled task:

  • Create a basic task and give it a name
  • set the time(s) for it to run
  • For action select “Start a Program” and fill out as per below:

program/script should link to the powershell.exe (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe) Add arguments should be the full path to the .ps1 script you want to run. (C:\scripts\testScript.ps1)

Click next, on the next screen tick the box “Open the Properties dialogue for this task when I click Finish” You will need to configure some security options:

  • Run the task with an administrator account
  • Select “Run whether user is logged on or now
  • select “Run with highest privileges”
  • Set Configure for to the current version of Windows Server

Test the task by manually running it. A successful run should show a “Last Run Result” of “(0x0).