Upgrade your VMs virtual hardware to the latest version.

This code will upgrade your VMs virtual hardware level to the highest available value for the host its running on.
I’ve also added some checks and limits that you can remove, change, or add as needed.
**Note, you must power off the VM to upgrade the virtual hardware so be sure you want to do that before running this script.

The code will do the following:
– check if the tools are updated/current.
– – if tools are current, check for a windows OS config in the vmx.
– – – if windows VM, shutdown the vm OS, wait until its in a “poweredoff” state, then update the virtual hardware and confirm the prompt to upgrade.

All you need to do is change this var to your VMs name and paste the code below it.
$vmname = “MyVMName”

$checkToolsStatus = Get-VM $vmname | %{$_.Guest.Extensiondata.ToolsVersionStatus}
if($checkToolsStatus -match “guestToolsCurrent”){
$GuestOSCheck = Get-VM $vmname | Get-View | %{$_.Summary.Config.GuestFullName}
if($GuestOSCheck -match “Windows”){
Get-VM $vmname | Shutdown-VMGuest
do {
sleep 3
$vmcheck = get-vm $vmname | %{$_.powerstate}
} until ($vmcheck -match “PoweredOff”)
$id=(get-vm $vmname).id
$vmview=get-view -id $id
$param = @($null)
$vmview.gettype().GetMethod(“UpgradeVM_Task”).Invoke($vmview,$param)
sleep 5
get-vm $vmname | get-vmquestion | set-vmquestion -defaultOption -confirm:$false
}else{
$GuestOSCheck
}
}else{
$checkToolsStatus
}

VMware Links:
https://www.vmware.com/support/developer/PowerCLI/PowerCLI51/html/Get-VM.html
http://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/Get-VMQuestion.html