Extensions

VM Tools and Virtual Hardware Versions

Alan Renouf, Sr Technical Marketing Architect, VMware

After reading Kyle’s post on the ESXi Chronicles blog here (I didn’t know you could do that) I wanted to show how you could gather and also export the Tools and Virtual Hardware Version in PowerCLI, this also allows us to use one of my favorite cmdlets New-VIProperty, a great post on this cmdlet can be found here.

If we look at the  object which gets returned back when we use the Get-VM cmdlet you will see that there is a root property for the Name, PowerState, NumCPU and many many more, one of these is the Version, this shows the hardware version so its easy enough to grab each VM’s name and Hardware Version by using:

Get-VM | Select Name, Version

But the returned object doesn’t have a root property for ToolsVersion or ToolsVersionStatus, for this we need to delve into the ExtensionData property and have a look around, once we have found the information it is fairly easy to add these to our object using the New-VIProperty cmdlet as below:

New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine
    -ValueFromExtensionProperty 'Config.tools.ToolsVersion'

    -Force

New-VIProperty -Name ToolsVersionStatus -ObjectType VirtualMachine
    -ValueFromExtensionProperty 'Guest.ToolsVersionStatus'

    -Force

Now we have added these as a new property to our object (actually they are PowerShell Code Properties), we can use our old friend Get-VM to retrieve the information easily:

Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus

image

Of course we can choose which list of VMs to get this information for:

For a Datacenter: Get-Datacenter London | Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus

For a cluster: Get-Cluster Production | Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus

For a host: Get-VMHost Host1.mydomain.local | Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus

And we can also easily export this information into a csv file:

Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus | Export-Csv -NoTypeInformation -UseCulture -Path C:\Temp\VMHWandToolsInfo.csv