MSExchangeGuru.com

Learn Exchange the Guru way !!!

 

How to Use Task Scheduler to schedule PowerShell Scripts

The task scheduler may be used to automatic run PS scripts on regular basis or one time which will be explained on this article.

First you should create a PS script and save it as .PS1 file on known path for example E:scripts

  • Open Task scheduler – Task scheduler Library – create task


  • Then you should find the 1st tab of configuration “General” as following:


    • Name: Specify the Friendly Name of Task.
    • Author: the Name of task creator.
    • Description: you can add optional description for the task purpose.
    • Then choose if the task may be run when you are not logging on the server or not; if you will run it automatically and it need access remote resources then computer will store the credential of your account or any other account you may specify that will run the task.
  • Then open the next tab “Triggers” — New as following:


    • You may need to multiple triggers
    • First you will specify when the task should be running and you have many options for this


    • If you choose on schedule you should choose the first time the task will run and if it will repeated as a regular basis or only one time.
    • Then you may need to add the time when the task will be expired and stopped to work.
    • You should mark enabled check if you want this trigger to be effective.
    • We may need to specify the time period that if task stuck more than it then it will be stopped.
  • Then open the next tab “Actions” — New as following:


    • You should choose the action type as following:


    • You may need to create more than one action on our case you should choose start a program
    • Then on Program field you should choose the path of PowerShell program “C:windowssystem32WindowsPowerShellv1.0powershell.exe”
    • Then on add arguments you will add the path of script as following “-ExecutionPolicy Bypass -file “E:Scripttestscript.ps1”
  • Then open the next tab “Conditions” as following; you may need to add more Optional conditions to control the task running.


  • Then open the next tab “Settings” as following; you may need to add more Optional conditions to control the task running.


  • Then on last tab “History” you will find the history of the task every time the task run on it.

Ratish Nair

Microsoft MVP | Office Servers and Services

Team @MSExchangeGuru


One Response to “How to Use Task Scheduler to schedule PowerShell Scripts”

  1. Monthly IT Newsletter – November 2017–January 2018 – Guy UC World Says:

    […] How to Use Task Scheduler to schedule PowerShell Scripts […]

Leave a Reply

Categories

Archives

MSExchangeGuru.com