Since the release of the vCenter Update Manager PowerCLI cmdlets back in march last year. I was hoping to find some time to play with it. Now this weekend I had some spare time to finally play with these new cmdlets. So I downloaded the setup file from http://communities.vmware.com and installed it on my PC. Then I started to Google and searched for existing scripts. I a couple of good posts. One by @alanrenouf with a short introduction video and a post about staging the patches via the vCenter Update Manager PowerCLI cmdlets by Damian Karlson. But there are no copy-past-run scripts available to update a vSphere host. So I fired up PowerGUI script editor and started working on a function called Update-VMHost. This function performs the following steps during the update process of a vSphere host:
- Look for a baseline and attach it if necessary.
- Perform a scan of the host.
- Check for compliancy.
- If not compliant enter Maintenance mode.
- Show missing patches
- When the host is in Maintenance mode, start the remediation process.
- After the reboot of the host, exit Maintenance mode.
That’s pretty much it. If you want to use this function, you can copy it from the end of this post and paste it inside the PowerCLI screen.