AndersonPatricio.ca

A Microsoft Unified Communications resource blog

Recent Posts

Search by Topic

Email Notifications

Blogroll

My Microsoft KBs

.:. About me..

Microsoft Community

Andy's Toolbox

Archives

Ads

How to schedule PowerShell scripts using Windows Tasks

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:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • Add arguments (optional) field
    -NoLogo -NonInteractive -File C:\path\yourscript.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
Leave a Comment

(required) 

(required) 

(optional)
 

(required) 

If you can't read this number refresh your screen
Enter the numbers above: