Hey All,
is there a way to get a list of all supported/available (or only the latest) virtual hardware version via powercli?
enviroment: vSphere 6.7U3
Afaik that is not available programmatically, only through the VMware provided tables as for example in KB2007240
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Afaik that is not available programmatically, only through the VMware provided tables as for example in KB2007240
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks LucD
😞 not nice.
I tried something like the way to get all available guestOS ID's [VMware.Vim.VirtualMachineGuestOSIdentifier].GetEnumValues() but no luck.....
The problem is that the CMD New-VM without the HardwareVersion option creates the vm with hardwareversion vmx-14 not vmx-15. But the CMD Doc's say "...By default, the new virtual machine is created with the highest available version..."
So i had the idea to first get the current hardwareversion and do a "autofill" for that parameter.... But how does the CMD New-VM get's the current HardwareVersion?
I'm using PowershellCore 6.2.3 and VMwareCLI-11.5.0-14912921
Vmx-15 only adds the ability to configure a VM with 256 vCPU instead of 128 vCPU in vmx-14.
And yes, the default HW version for new VMs (in vSphere 6.7 Update 2 and higher) is still vmx-14.
That is a 'known feature' I'm afraid.
You can easily change the default HW version on the datacenter or cluster.
But remember, vmx-15 is only available since vSphere 6.7 Update 2.
$spec.DefaultHardwareVersionKey = 'vmx-15'
$modify = $true
$dc = Get-Datacenter -Name MyDC
$dc.ExtensionData.ReconfigureDatacenter_Task($spec, $modify)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks to the information provided by LucD I could write a piece of code which does the job.
param(
[Parameter(
Mandatory,
ValueFromPipeline
)]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$VMHost
)
process {
foreach ($VMHostItem in $VMHost) {
[PSCustomObject]@{
Name = $VMHostItem.Name
VHardwareCapability = switch ([int]$VMHostItem.ExtensionData.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 7.0
{ $PSItem -ge 15843807 } { '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 { 'Unknow ESXi version' }
}
}
}
}
}
Get-VMHost | Get-VMHostVHardwareCapability
Great idea, but the problem with this approach, is that some of the version numbers overlap.
For example ESXi 7.0 GA (15843807) is lower than ESXI 6.7 EP18 (17499825)
I realise this is an older post
here is a code snipit to grab the hardware available hardware versions
$VIServer = 'VIServer-Name'
Connect-VIServer -Server $VIServer
$VMWareCluster = Get-Cluster -Name 'ClusterName'
$VMWareVersions = (Get-View $VMWareCluster.ExtensionData.EnvironmentBrowser).QueryConfigOptionDescriptor()
$Results = foreach ($SingleVersion in $VMWareVersions)
{
$HostsDetail = foreach ($SingleHost in $SingleVersion.host)
{
Get-VMHost -Id "$($SingleHost.type)-$($SingleHost.value)"
}
[pscustomobject]@{
Version = $SingleVersion.key
Name = $SingleVersion.Description
Create = $SingleVersion.CreateSupported
Run = $SingleVersion.RunSupported
Hosts = $HostsDetail.Name
}
}
$Results | Format-Table -AutoSize
Hope that helps someone that comes looking later on
Nice find, I didn't know about that method.
As an addition, and more in line with the table in KB2007240, the following lists for all your ESXi nodes (including the standalone ones), the Name, Version, and default HW version.
And also which version you can Create, Edit, or Run on that specific ESXi node.
Get-View -ViewType ComputeResource -PipelineVariable cResource |
ForEach-Object -Process {
if ($cResource -is [VMware.Vim.ClusterComputeResource]) {
$envBrowser = Get-View -Id $cResource.EnvironmentBrowser
$esx = Get-View -Id $cResource.Host
$cluster = $cResource
} else {
$envBrowser = Get-View -Id $cResource.EnvironmentBrowser
$esx = Get-View -Id $cResource.Host
$cluster = ''
}
$esx | ForEach-Object -Process {
$versions = $envBrowser.QueryConfigOptionDescriptor()
[PSCustomObject]@{
VMHost = $_.Name
Cluster = $cluster.Name
Version = $_.Config.Product.FullName
DefaultHWVersion = ($versions.Where{ $_.DefaultConfigOption }).Key -join '|'
Create = ($versions.Where{ $_.CreateSupported }).Key -join '|'
Run = ($versions.Where{ $_.RunSupported }).Key -join '|'
Edit = ($versions.Where{ $_.UpgradeSupported }).Key -join '|'
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference