Summary: How to schedule a task on Windows Server 2008 to start a powershell script.
Date: Around 2010
Refactor: 1 May 2025: Checked links and formatting.
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.
In this example I'll create a task for scheduling a powershell/powercli script as explained in powercli-dailycheck. Before you start creating the task you'll need an service account which has the following permissions:
Then the task:
-PSConsoleFile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "& 'C:\Users\Public\Documents\dailycheck.ps1'" vcenter
Note: On a Windows Server 2008 R2 server and a script which loads the VMware modules itself I had to create the following action:
-nologo -noninteractive -command "&{D:\Scripts\SRM-Reports\srmreports.ps1}"
When you click OK the task will ask you for the password of the service account you provided in the General tab.
Arguments on Windows Server 2016 with a script on a remote repository:-Executionpolicy Bypass -nologo -noninteractive -command "& {\\fileserver\dfs\SCRIPT_REPOSITORY$\ICTScripts\script.ps1}"
You can test whether the task runs by right-clicking the task and clicking “run”.
> c:\temp\logfile.txt
When troubleshooting you might want to completely remove scheduled tasks. If you want to make sure that a task is completely removed you can check both the filesystem and the registry:
Filesystem:
%systemroot%\System32\Tasks %systemroot%\Tasks
Registry:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Schedule\Taskcache\Tasks HKLM\Software\Microsoft\Windows NT\CurrentVersion\Schedule\Taskcache\Tree
Note that if you recreate the task with the same name, the old history is still displayed. As the ID of the task changes on recreation it probably checks the eventlog based on the name.