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:

general.PNG

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

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.

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"

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.

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.

-- JoannaHulboj - 25-Oct-2010

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng general.PNG r1 manage 13.9 K 2010-10-25 - 19:36 UnknownUser  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2010-10-25 - unknown
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

  • Edit
  • Attach
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