You might need to update this function I wrote a while back, but this will get you started.
Function Get-VMHostVHardwareCapability{
<#
.SYNOPSIS
Displays highest VM virtual hardware version compatible with the VMHost ESXi version
.NOTES
https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/How-to-get-a-list-of-all-supported-virtual-hardware-versions-via/td-p/523121
[VMware.Vim.VirtualMachineGuestOSIdentifier].GetEnumValues()
#>
param(
[Parameter(Mandatory=$FALSE, ValueFromPipeline)][VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl]$VMHost,
[Parameter(Mandatory=$FALSE, ValueFromPipeline)][VMware.Vim.HostSystem]$VMhostView
#[Parameter(Mandatory, ValueFromPipeline)][VMware.Vim.HostSystem]$VMhostView
#[Parameter(Mandatory, ValueFromPipeline)][VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$VMHost,
)
process {
IF($VMHost){$VMHostView = $VMHost.ExtensionData}
foreach ($VMHostItem in $VMhostView) {
IF(!($Global:VMwareVersions)){
IF((Get-Module -Name VirtOps -ListAvailable).ModuleBase){
Test-Path -Path $(((Get-Module -Name VirtOps -ListAvailable).ModuleBase) + "\Public\VMware OS and Tools Version Tables.csv")
$global:VMwareVersions = Import-CSV -Path $(((Get-Module -Name VirtOps -ListAvailable).ModuleBase) + "\Public\VMware OS and Tools Version Tables.csv")
}
}
IF($Global:VMwareVersions){
$VMwareVersion = $Global:VMwareVersions | ?{($_.ESXiBuild -eq $VMHostItem.Config.Product.Build) -AND ($_.ESXiVersion -Match (($VMHostItem.Config.Product.Version).Split('.')[0]))}
[PSCustomObject]@{
Name = $VMHostItem.Name
VHardwareCapability = $VMwareVersion.vHW
ESXiVersion = $VMHostItem.Config.Product.FullName
}
}Else{
#The Problem with this approach is that later releases of lower versions can have a higher build number that earlier releases of higher versions.
#Starting with the highest build numbers in the SWITCH SHOULD minimize the occurances of this Build number to ESXi version mismatch
[PSCustomObject]@{
Name = $VMHostItem.Name
VHardwareCapability = switch ([int]$VMHostItem.Config.Product.Build) {
#Release numbers can be found here: https://kb.vmware.com/s/article/2143832
#Hardware versions can be found here: https://kb.vmware.com/s/article/2007240
#ESXi 8.0
{ $PSItem -ge 20513097 } { 'vmx-20' }
#ESXi 7.0U2
{ $PSItem -ge 17630552 -and $PSItem -lt 20513097 } { 'vmx-19' }
#ESXi 7.0U1
{ $PSItem -ge 16850804 -and $PSItem -lt 17630552 } { 'vmx-18' }
#ESXi 7.0
{ $PSItem -ge 15843807 -and $PSItem -lt 16850804 } { 'vmx-17' }
#ESXi 6.7 U2
{ $PSItem -ge 13006603 -and $PSItem -lt 15843807 } { 'vmx-15' }
#ESXi 6.7
{ $PSItem -ge 8169922 -and $PSItem -lt 13006603 } { 'vmx-14' }
#ESXi 6.5
{ $PSItem -ge 4564106 -and $PSItem -lt 8169922 } { 'vmx-13' }
#ESXi 6.0
{ $PSItem -ge 2494585 -and $PSItem -lt 4564106 } { 'vmx-11' }
#ESXi 5.5
{ $PSItem -ge 1331820 -and $PSItem -lt 2494585 } { 'vmx-10' }
#ESXi 5.1
{ $PSItem -ge 799733 -and $PSItem -lt 1331820 } { 'vmx-9' }
#ESXi 5.0
{ $PSItem -ge 469512 -and $PSItem -lt 799733 } { 'vmx-8' }
#ESXi/ESX 4.x
{ $PSItem -ge 164009 -and $PSItem -lt 469512 } { 'vmx-7' }
Default { 'Unknown ESXi version' }
}
ESXiVersion = $VMHostItem.Config.Product.FullName
}
}
}
}
}
-------------------------------------------