Good news is that it only takes 200+ updates and hours of wasted time to patch a fresh installation of Windows Server 2012 R2 server.
One solution we've decided to streamline this task is to maintain a patched virtual machine (VM) template that has the most current Windows updates needed.
"That's a great idea, but you're still having to maintain a VM template." you might say.
Yeah, I don't have to maintain it - my scheduled task that kicks off a PowerCLI/PowerShell script maintains our VM template.
You can find the latest version at: https://github.com/cajeeper/PowerCLI/blob/master/Install-Windows-Update-for-Template.ps1
Here's a breakdown on what this script does:
- Converts the VM template to a virtual machine
- Starts the virtual machine
- Issues PowerShell script block via VMWare Tools to trigger and install any needed Windows updates
- Sleeps for 10 minutes to allow Windows Updates to reboot the OS as needed
- Shuts the virtual machine down
- Converts the virtual machine back to a VM template
- Logs the results
- Creates copy of template to another system/site
- Shows the progress via the CLI
I've been using it for the last few months with success, so I figured its time to share - once again. Note: I've only been testing this on a Windows Server 2012 VM template.
Requirements for the script to function:
- An existing Windows VM template that has VMware Tools installed and a network adapter to recieve Windows Updates
- VMware vCenter - Tested on v
- A user/service account with permissions to Create, Remove, Start, Stop VMs and issue VM scripting commands in vCenter 6.0.0
- A user/service account with permissions to install Windows Updates in the template virtual machine
- Update the parameters with all your relevant template, location, etc. and if you want a post copy of the template to kick off.
Here's the last few months of Windows Updates that have been installed on every Fridays for my virtual machine template via this script:
|Template Virtual Machine - Windows Update History|
|Template Virtual Machine - Recent Scripted Tasks and Copy of Template at Dev1 Datacenter|
Best of luck!