Within large enterprise organizations or maybe even small businesses, it can be a pain in the ass to update the virtual hardware version. In most cases, it is not necessary to update the VM hardware version, but a lot of customers do want you to upgrade the virtual hardware version so that it matches the same version of the rest of the environment.
Note: VMware does not recommend upgrading the virtual hardware version if you do not need the new features exposed by the new version.
There a several ways you can upgrade the virtual hardware version. This can be done using the GUI or CLI. To make things easy for you, I created a Powershell script. This script makes it possible to update the virtual hardware version the same way, you can auto-update the VMware tools.
Upgrade the Virtual Hardware Version via the GUI
First, let me show you how you can upgrade the VM hardware version using the GUI in vCenter.
- Log on to the vCenter Server
- Navigate to the Virtual Machine you would like to upgrade and select the VM
- Click on the Updates tab and click on CHECK STATUS
- Make sure the VMware Tools are up-to-date
- Before you upgrade the virtual hardware version, make sure you have a backup or take a snapshot
- Now you can upgrade the VM Hardware Version
- Click on UPGRADE TO MATCH HOST
- Click on Scheduling Options if you want to schedule the upgrade
- Click on Rollback Options to check the snapshot settings (this can be configured in LifeCycle Manager)
- Click on UPGRADE TO MATCH HOST to start the upgrade, the VM will reboot in the process
Using the GUI to upgrade the virtual hardware version can be a time-consuming job. You have to do this manually on each VM. I can only imagine you have better things to do!
Upgrade the Virtual Hardware Version via Powershell
If you use Powershell to upgrade the virtual hardware version, you can pre-stage the upgrade of all VMs at once. The script I created is fairly simple but very effective. Do not worry, if you run the script nothing happens with the virtual machine(s). We will only set a schedule with the script that on a reboot of the VM (any place any time anywhere) the virtual hardware is upgraded.
You can change the values in the script if you like. I only wanted to update VMs that were on version v14 and upgrade them to v19. To get a better overview of the VM hardware version, click here.
- Make sure the VMware Tools are up-to-date or auto-update is set to on
- If you want to use this script, make sure you have daily backups of the VMs, because this script does not make a snapshot!
- Now you can execute the script
Install the VMware.PowerCLI module if necessary
Install-Module VMware.PowerCLI -Scope CurrentUser
Log on to the Center with an admin account that has sufficient privileges
Connect-VIServer (IP or FQDN vcenter) -Protocol https -User (username) -Password (password)
Using the “Group-Object” cmdlet we can run up a quick count of all the VMs on each hardware version
Get-VM | Group-Object Version
Update VM Hardware Version from V14 (change value for other versions) to V19 for VMs with Windows Guest OS
$HardwareUpdateVMs = (Get-VM).where{$_.PowerState -eq 'PoweredOn' -and $_.Version -match 'V14' -and $_.Guest.OSFullName -match 'Windows'} | Out-GridView -PassThru Foreach ($VM in ($HardwareUpdateVMs)) { $VMConfig = Get-View -VIObject $VM.Name $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.ScheduledHardwareUpgradeInfo = New-Object -TypeName VMware.Vim.ScheduledHardwareUpgradeInfo $vmConfigSpec.ScheduledHardwareUpgradeInfo.UpgradePolicy = “always” $vmConfigSpec.ScheduledHardwareUpgradeInfo.VersionKey = “vmx-19” $VMConfig.ReconfigVM($vmConfigSpec) }
In this script, I use the out-grid view, so you will get an overview of all VMs. The only thing you have to do is select the VMs you want to upgrade and click on OK. You can also make a filter or add criteria if you like.
Now we have executed the script, the only thing that needs to be done is reboot the VM and the virtual hardware is upgraded. This works exactly the same as with the auto-update feature of the VMware tools.
Summary
That’s all folks!
Please get in touch with me or leave a comment, if you have any questions or want more information on this or other topics.