You never know when you’ll need to script something and PowerCLI gives you the tools to do it. I decided to see if I could script some of the VMware Update Manager (VUM) tasks while I was reviewing section 5.2 of the VCAP5-DCA Beta Blueprint and found that the procedures were quite easy. My next thought was, “Why would I want to script this when I can use the GUI, and on top of that I can schedule scans and remediation already?” My answer was, “You never know.” Who knows when you’ll need to use the PowerCLI to accomplish a task. Maybe, you’re scripting something so someone else can run it without really knowing how to perform the task, or you’re trying to get a report, or who knows.
Here is a basic procedure to scan and remediate some ESX hosts.
You must have PowerCLI and the VUM cmdlets installed before you can run any of these commands.
First, we’ll create a patch baseline. In this case the patch baseline will get dynamic updates that are for ESXi hosts, only critical VMware Updates, and released after May 1st 2012. We’ve named the baseline “PowerCLIBaseline.”
new-patchbaseline -dynamic -name PowerCLIBaseline -description "PowerCLI Baseline Example -TargetType Host -SearchPatchVendor *VMware* -SearchPatchSeverity critical -SearchPatchStartDate 5.1.2012