Tuesday, August 13, 2013

Keeping VMTools ALWAYS up to date

Dear sysadmins out there, how do you guys keep the VMtools and virtual hardware up to date, all the time? Less than 20 VM would still be manageable, but hundreds of them, with some are in live production environment is not an easy task.

The task should be split into two parts:
1) Get all the VMtools up to date
2) Upgrade virtual hardware

This would require at least 2 downtimes. First downtime is a reboot once VMtools installed. 2nd downtime is to power off the VM and do the virtual hardware upgrade. Note that virtual hardware should only be upgraded once the VMtools is updated or you might lose the network setting on that VM.

There is an option to keep the VMtools checked during each power cycle. Found a link to get that massed using powerCLI (http://damiankarlson.com/2011/01/23/managing-vmware-tools-advanced-options-powercli/) but for the first round it could be the manual option. 

1st update:
One liner to get the VMtool and virtual hardware version status:
Get-VM | select Name,Version,@{N="Tools Status";E={$_.Guest.Extensiondata.ToolsVersionStatus}}

2nd Update:
One liner is not good enough, my plan is to align the VMtool upgrade during patching windows (subject to approval)

first, script to get the details.

Function Get-myPatchingReport {
#sample get-vm | % { Get-myPatchingReport $_ } | ft -a
param ($VM)
$report = @()
$row = "" | select Name, OS, Version, ToolStatus
$v = get-vm $VM | get-view
$get = get-vm $VM
$row.Name = $VM
$row.OS = $v.Guest.GuestFullName
$row.Version = $get.Version
$row.ToolStatus = $get.Guest.Extensiondata.ToolsVersionStatus
$report += $row
$report
}
export the report to csv/xls and compare to the patching master list for the exact window. Since some VMs are still running Win2k3, they will not be in patching list. Thus, the Guest OS that is captured from the script.

Going to update this (again) later after I got some live data.
*edit: script was badly coded it will create large temp files and took very long time to complete if you have large environment. will work for about 20-30 vm. else just export the list from vcenter.