Advertise on warmetal.nl!
Click for more information
about advertising here.

Did you find this website useful? Did I save you a lot of time?
Please consider donating to support this site:

 

Schedule Tasks on Windows Server 2008

The location of the Windows Server 2008 Task Scheduler is a little bit changed. You can find it by starting Server manager → Configuration → Task Scheduler. If you created custom tasks you can find them under Task Scheduler → Task Scheduler Library.

Creating a Task

In this example I'll create a task for scheduling a powershell/powercli script as explained in Script: PowerCLI: Daily Check. Before you start creating the task you'll need an service account which has the following permissions:
  • Logon as a batchjob
    • Control Panel → Administrative Tools → Open Local Security Policy.
    • Go to Local Policies → User Rights Assignments.
    • Go to Log on as a batchjob.
    • Click Add User or Group, and add the service account to the list of accounts.
  • vCenter permissions
    • Go to the permissions tab of the vCenter and add the user while assigning read-only rights and propagating this to all child objects.

Than the task:

  • Click on Create Task
  • In the General tab:
    • Give a name and description
    • Use the created service account to run the task
    • Set the task to “Run whether user is logged on or not”
    • Check the “Run with highest privileges
    • Configure the task for the correct Operating System (Windows Server 2008 / Windows Server 2008 R2)
  • On the Triggers tab create a new trigger based on what time you want the task to start (Daily - 07:30).
  • On the Action tab create a new action:
    • Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    • Arguments: -PSConsoleFile “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” ”& 'C:\Users\Public\Documents\dailycheck.ps1'” vcenter
  • On the Settings tab set the task to stop if it runs longer than 1 hour.

When you click OK the task will ask you for the password of the service account you provided in the General tab.

Test the Task

You can test whether the task runs by right-clicking the task and clicking “run”.

Troubleshooting

0x1 - Do not create a batch file for the script but set it up as explained above.
0x41301 - Actually, the batch file is running. Please wait for the script to finish.
0x80070569 - The user does not have “logon as a batchjob” permissions. Assign the rights as explained above.

Discussion

Enter your comment:
 
win2008tasks.txt · Last modified: 2011/06/30 10:13 by sjoerd