sg-ascension
Contributor
Contributor

Get highest HW version supported by Cluster for Virtual Machine (Template)

Hello all,

  I have multiple vCenters that are at different versions some current, but others as low as 6.0. Within each of those vCenters there can be multiple DataCenters, with multiple Clusters. I am trying to find a way of getting the highest supported version of the VM Hardware Version that a cluster should be able to support. 

 Based on some other scripts (A BIG THANK YOU to LUC for giving help to the community), I have the following to get the possible guest Families, guest Full Name's and ID's

$vcenters = (get-content -Path vcenters.txt)
foreach($vcenter in $vcenters) {
write-host "vCenter is $vcenter"
connect-viserver -Server $vcenter -Credential (get-credential)
foreach($Datacenter in Get-Datacenter -Server $vcenter) {
write-host "Datacenter is $Datacenter"
foreach ($cluster in Get-Cluster -Location $DataCenter) {
write-host "Cluster is $cluster"
foreach($esxhost in (Get-VMHost -Location $cluster | Select-Object -First 1)){
write-host "Host is $esxhost"
$viewObjEnvBrowser = Get-View -Id (Get-View -Id $esxHost.ExtensionData.Parent).EnvironmentBrowser
$vmxVer = ($viewObjEnvBrowser.QueryConfigOptionDescriptor() | Where-Object {$_.DefaultConfigOption}).Key
$osDesc = $viewObjEnvBrowser.QueryConfigOption($vmxVer,$esxHost.ExtensionData.MoRef).GuestOSDescriptor
$osDesc | Select-Object -Property Family, FullName, ID
}
}
}
}

The ultimate goal is for the data to be used to update templates that when they are being cloned from the content library thru PowerCli as a VM (then converted back to a Template) to have the correct VMX HW Version level, Guest version for the Cluster it is being deployed to. (Please note the VM's are sealed, so opening them todo highest might not be an option and Template names are as an example windows-2019-template or redhat-8-template, so a switch statement might work)

 Any help would be appreciated. 

0 Kudos
2 Replies
LucD
Leadership
Leadership

Have a look at Solved: Re: How to get a list of all supported virtual har... - VMware Technology Network VMTN

With a big thank you to  _BT_Black_V who found that method.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

sg-ascension
Contributor
Contributor

Thank you Luc, I think that is what I am going to be able to use to help out the operations team.

0 Kudos