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.
https://vchamp.net/powercli-upgrade-vm-hardware-compatibility-version-from-csv/