Sample Exchange

 View Only

vSphere - Upgrade VM Hardware Compatibility from CSV 

Jun 10, 2024 09:28 AM

vSphere Administrators may determine that it is necessary to upgrade the Virtual Machine Hardware Compatibility version across multiple VMs as a matter of maintaining lifecycle, in response to security advisories, or to benefit from new and improved features. This PowerCLI script enables the vSphere Administrator to supply a list of scoped VMs in the form of a CSV file and run the script to set a flag on each VM to upgrade the Hardware Compatibility version at next power cycle (soft power cycle via Guest OS reboot is acceptable). The script will not facilitate the reboot action - simply setting the upgrade flag. This permits each VM to reboot according to their prescribed maintenance windows (i.e., routine patching) in favor of potentially rebooting many VMs at once.

Requirements

  • The user credentials provided within the PowerShell terminal must have adequate permissions to retrieve and update the VM configuration in vCenter.
  • User must have adequate rights to save log output file to the working directory on the local system running the script. Run PowerShell with elevation (as Administrator) as needed.
  • User must provide a list of scoped VMs in the form of a CSV file located in the same directory as the script.
    • The VM Name(s) must be listed beneath a column heading titled "Name". (i.e., Cell A1 should say "Name" and cells A2 and below should contain VM names)
  • The VM name(s) must match according to vCenter, not the DNS hostname if different.

Instructions

  1. Download the "Upgrade_Hardware_Compatibility.zip" file and extract to a directory on your local workstation.
  2. Open the "PUT_VM_Properties_Upgrade_Hardware_Compatibility.ps1" script in an editor of your choice. Modify the Hardware Compatibility version on line 35 if needed, as the script is configured to target version 19 currently. Save once complete.
  3. Open the "vm_hardware_upgrade.csv" file in an editor of your choice. Replace the sample VM names with names which apply to your environment. Ensure each VM name is on a separate line and the "Name" heading remains at the top. Save once complete.
  4. Launch a PowerShell window/session and change directories to the directory containing the script, as needed. (i.e., cd C:\Scripts)
  5. Execute the script (.\PUT_VM_Properties_Upgrade_Hardware_Compatibility.ps1)
  6. The “Main Menu” is presented, which prompts the user to specify the Fully Qualified Domain Name (FQDN) of the vCenter server. Type the vCenter FQDN, then press the Enter key.
  7. The next prompt asks for the user’s credentials for authentication to the vCenter server. Type your credentials, then press the Enter key.
  8. The script will now loop through the list of provided VMs. If the scoped VMs are located on the target vCenter Server and are configured with a virtual hardware version less than the version we specified, an attribute will be set to upgrade the hardware compatibility version on the VM’s next power cycle, which can be gracefully executed from the Guest OS – it does not need to be a full power cycle where the VM is properly reset and powered off/on by the hypervisor.
  9. Upon completion, the user session between PowerShell/PowerCLI and the target vCenter server will be automatically disconnected at the end of the script.

Walkthrough

https://vchamp.net/powercli-upgrade-vm-hardware-compatibility-version-from-csv/


#PowerCLI

Statistics
1 Favorited
62 Views
1 Files
0 Shares
4 Downloads
Attachment(s)
zip file
Upgrade_Hardware_Compatibility.zip   2 KB   1 version
Uploaded - Jun 10, 2024

Tags and Keywords

Related Entries and Links

No Related Resource entered.