How to use the Windows Task Scheduler to run a Powershell script

Task Scheduler allows for scheduling periodical tasks under Windows. To launch it follow the directions below:

  • Start->Administrative Tools->Task Scheduler.
  • Action->Create Task.

Task Scheduler management console will appear. It will look somewhat similar to what is shown in Figure 1:

Figure 1:


In order to schedule a new task select the “Create Task…” option from the “Actions” menu on the right. Configuration window will appear (Figure 2). It is necessary to provide the basic information about the task:

  • Task name – it will be visible under this name in the list of task
  • Checkbox “Run whether user is logged or not” should be checked – otherwise the task will not run if the user is logged off.
  • Check that the right user account for the task is being provided

Figure 2:


Then it is necessary to specify when the task is supposed to be executed. This configuration can be done under the “Triggers” tab. Figure 3 shows an example of the trigger configuration.

Figure 3:


Next step is to configure the action to be executed. This is done in the “Actions” tab. If one wishes to run a Powershell script then it is important to use the appropriate syntax (see also Figure 4):

  • Program/script: cmd.exe
  • Add arguments (optional): /c "powershell C:\Backup\transferFile.ps1"

Figure 4:


The last two tabs: “Conditions” and “Settings” contain specific options that allow for further customisation of the task behaviour. Figure 5 and 6 show sample settings.

Figure 5:


Figure 6:


After the task has been created, an additional tab becomes accessible: “History”. It displays all the information about the status of the particular task. There are logs which allows as to checks whether the task was completed successfully or whether it has failed.

Figure 7:


-- JoannaHulboj - 25-Oct-2010

Topic attachments
I AttachmentSorted ascending History Action Size Date Who Comment
PNGpng conditions.PNG r1 manage 15.8 K 2010-10-26 - 08:27 UnknownUser  
PNGpng general.PNG r1 manage 13.9 K 2010-10-25 - 19:36 UnknownUser  
PNGpng history.PNG r1 manage 19.4 K 2010-10-26 - 08:38 UnknownUser  
PNGpng newAction.PNG r1 manage 8.5 K 2010-10-26 - 08:55 UnknownUser  
PNGpng newHistory.PNG r1 manage 19.1 K 2010-10-26 - 08:54 UnknownUser  
PNGpng newTrigger.PNG r1 manage 15.8 K 2010-10-26 - 08:55 UnknownUser  
PNGpng settings.PNG r1 manage 15.5 K 2010-10-26 - 08:35 UnknownUser  
PNGpng viewAll.PNG r1 manage 56.1 K 2010-10-26 - 09:07 UnknownUser  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2010-10-26 - unknown
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback