Your workloads are constantly changing both from an application standpoint but also the underlying guest operating system (GuestOS) including patches and upgrades. While many organizations have a change management database (CMDB), it can still be a challenge to true up that information from when the workload was first deployed to what it is currently running.
Back in 2019, VMware enhanced VMware Tools to make it easier to identify applications and processes that was running within a VM and this also provided a programmatic way for retrieving this inventory information which could then be fed back into their CMDB.
Applications are not the only things that change inside of a VM, the GuestOS probably receives the most updates (patches/upgrades) and being able to accurately inventory this information without relying on an in-guest agent is still a challenge for many.
In vSphere 8.0 Update 2, we have enhanced the available GuestOS data using VMware Tools and we have also made it easier to inventory and collect this information even when the VM has been powered off.
A new guestDetailedData vSphere API property has been introduced, which can contain the following 10 fields, which are populated by VMware Tools:
Field | Description | VMware Tools Version Required |
---|---|---|
architecture | Arm or X86 | 11.2.0 |
bitness | 32 or 64 | 11.2.0 |
buildNumber | OS build number | 11.2.0 |
cpeString | NIST Common Platform Enumeration Specification standardized identifier string for the OS | 11.2.0 |
distroAddlVersion | Longer OS version string that may contain additional info (e.g. version name) | 12.2.0 |
distroName | OS distribution name | 11.2.0 |
distroVersion | OS version string | 11.2.0 |
familyName | OS family name (Windows; Linux; etc.) | 11.2.0 |
kernelVersion | Linux kernel version or Windows 10+ patch number or Windows build number | 11.2.0 |
prettyName | Officially specified distro "pretty name" | 11.2.0 |
As you can see, you will need to have at least VMware Tools 11.2.0 or 12.2.0 to see all of these fields. The API property can be retrieved while the VM is powered on and depending on the GuestOS, all or a subset of these fields will be available. When a VM is powered off, VMware Tools is no longer running and the property would be empty or null as expected.
The developers wanted to make it easier for users to retrieve this information, especially if it has not changed from the last time it was collected and make this persistent so that you can quickly inventory your VMs even if it is powered off. As mentioned in the vSphere API documentation, the last known values are persisted and is available when the VM is powered off. This information is stored in the VM Advanced Setting called guestinfo.detailed.data and will contain the last known values when the VM was running.
To make it even easier for our users to consume this new vSphere API, I have created the following PowerCLI snippet which will retrieve only this property for all VMs and store that into custom object which you can then process further:
$vms = Get-View -ViewType VirtualMachine -Property Name,Config.extraConfig $results = @() foreach ($vm in $vms) { $detailedData = ($vm.Config.ExtraConfig | where {$_.key -eq 'guestInfo.detailed.data'}).Value # Split the pairs $keyValuePairs = $detailedData -split "(?<=') " -replace "'", "" # Clear variables $architecture = $bitness = $distroName = $buildNumber = $cpeString = $distroAddlVersion = $distroVersion = $familyName = $kernelVersion = $prettyName = $null # Loop through key-value pairs foreach ($pair in $keyValuePairs) { $key, $value = $pair -split '=', 2 if ($key -eq "architecture") { $architecture = $value } elseif ($key -eq "bitness") { $bitness = $value } elseif ($key -eq "buildNumber") { $buildNumber = $value } elseif ($key -eq "cpeString") { $cpeString = $value } elseif ($key -eq "distroAddlVersion") { $distroAddlVersion = $value } elseif ($key -eq "distroName") { $distroName = $value } elseif ($key -eq "distroVersion") { $distroVersion = $value } elseif ($key -eq "familyName") { $familyName = $value } elseif ($key -eq "kernelVersion") { $kernelVersion = $value } elseif ($key -eq "prettyName") { $prettyName = $value } } $tmp = [pscustomobject] [ordered]@{ Name = $vm.Name; Architecture = $architecture; Bitness = $bitness; BuildNumber = $buildNumber; CPEString = $cpeString; DistroName = $distroAddlVersion; DistroVersion = $distroName; DistroAddlVersion = $distroVersion; FamilyName = $familyName; KernelVersion = $kernelVersion; PrettyName = $prettyName; } $results+=$tmp } $results
Here is an example of what the output might look like:
Bill A says
This is something we've been wrestling with for quite a while, a very welcome addition in the tool box! Thanks for documenting, and creating a code snippet.
Robert says
Thanks for the great website William. I hope you are able to continue this after Broadcom takes over. Your blog is invaluable to VMware administrators.
Wee Sung Cheng says
Echoing many people, your documentation has me, and probably many others, gems that cannot be sourced anywhere else. Hope the transition to Broadcom goes will for you and teams.
Dan says
Small note cmdb commonly refers for configuration management database.
Thanks for highlighting this feature improvement.
Telkom University says
What specific enhancements have been made to the GuestOS data in the latest vSphere 8.0 Update 2 release?