How to schedule PowerShell scripts using Windows Tasks

Share this:

Hi Folks,

Last week I blogged here about PowerShell v3 and a new feature that is going to do the content of topic automatically however if you don’t have Windows 8/PowerShell 3 and you want to configure a script that you created to run on Windows Server 2008 R2 these following steps can be used:

If your script is not digitally signed, you can run the Set-ExecutionPolicy –ExecutionPolicy Unrestricted as shown in the figure below.

image

Now, it’s time to create a new Windows Task and what really matters for us is the Start a Program section, and these following values must be entered:

  • Program/Script field:
    C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
  • Add arguments (optional) field
    -NoLogo -NonInteractive -File C:pathyourscript.ps1

All pieces together are shown in the picture below.

image

That’s all my friends, from now your PowerShell scripts will work just fine. I do recommend to do a test and depending of the script you may want to configure a specific account to run on the Task and also to configure the script to

Cheers,
Anderson Patricio
http://www.andersonpatricio.ca
http://www.andersonpatricio.org (Portuguese)
Twitter: @apatricio

Written by Anderson Patricio

Anderson Patricio

Anderson Patricio is a Canadian MVP in Cloud and Datacenter Management, and Office Server and Services, besides the Microsoft Award he also holds a Solutions Master (MCSM) in Exchange and several other certifications. Anderson has been contributing to the Microsoft Community with articles, tutorials, blog posts, twitter, forums and book reviews. He is a regular contributor here at ITPROCentral.com, MSExchange.org, Techgenix.com and Anderson Patricio.org (Portuguese).