Randomizing the Windows Update start time
When working with persistent desktops in a virtual environment like VMware Horizon View, software installations have to be handled very carefully to avoid overwhelming shared resources. While some products like Microsoft’s System Center Configuration Manager include randomization features to spread out installations over a short window, Microsoft’s Windows Update does not include a similar function.
If you’ve ever had to configure Windows Update via group policy, you are probably familiar with the main “Configure Automatic Updates” screen. Below is a pretty typical configuration for desktop computers where you want installs to happen automatically in the middle of the night.
When the scheduled install time of 03:00 AM hits, all of the computers will begin installing their updates at the same time. To work around this problem, you could configure multiple group policies with different start times or even directly modify the registry
HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\ScheduledInstallTimesetting on different sets of computers. In either case this is not very useful, since you can only set the scheduled install time by hourly increments.
A better option is to use the Windows 7 Task Scheduler to perform the Windows Update operations. With the Task Scheduler, you can be extremely granular with your scheduling. The best feature of the scheduler is that you can delay task for a random interval:
Here is a script that I’ve adapted from a post on MSDN explaining the Windows Update API. This script will talk to your Windows Update server to identify required updates, download and install the updates, then reboot if nobody is logged into the computer. If a user is currently logged in, they will see the normal Windows Updates prompts to reboot. The script will also log the details to a log file created in the same directory.
The script can be easily installed to run from the Task Scheduler with the schtasks.exe command. Create a task with the settings you want, export it to an XML file, then use this command to install it.
schtasks.exe /Create /F /RU "SYSTEM" /NP /XML "WindowsUpdateRandomizer.xml" /TN "Windows Update Randomizer"