The Get-VMHostVersion and Get-VMHostLatestVersion PowerShell functions are aimed at helping you to identify the version at which your ESXi is currently running, and whether updates are available. Both are using a JSON based ESXi Build database which is also the backend for the ESXi Build Number History provided by virten.net.
The function is part of my Virten.net.VimAutomation module, which is a set of PowerShell function built for managing, troubleshooting and automating VMware based platforms. The module can be easily obtained from the PowerShell Gallery and is available on GitHub.
Install Virten.net.VimAutomation from PowerShell Gallery
The Virten.net PowerCLI Automation Module is available in the PowerShell Gallery.
PS> Install-Module -Name Virten.net.VimAutomation
Install Virten.net.VimAutomation from GitHub (Manual Installation)
The Virten.net PowerCLI Automation Module is also available on GitHub. To manually install this module, copy the Virten.net.VimAutomation folder (Download) into your local module directory. There are various module directories, they can be identified with the $env:PSModulePath
environment variable. Activate the module with PS> Import-Module Virten.net.VimAutomation -Force -Verbose
.
Get-VMHostVersion
The Get-VMHostVersion function returns more details about the installed ESXi versions. Depending on the Client, you can only see the ESXi Minor Release and a Build number. With this function, you can now determine when the installed version has been released and on which update release the ESXi is running, which might be important for HCL checks.
The function is intended to either take VMHosts through a pipeline (returned by Get-VMHost) or to run without parameters. If no parameter is given, it will return all ESXi Hosts connected to the vCenter Server.
Returned object
Property | Description |
VMHost | ESXi Hostname |
Build | ESXi Build Number |
Version | Version (Unambiguous friendly name used in Release Notes and https://kb.vmware.com/kb/2143832) |
ReleaseDate | Release Date (When the installed version has been published) |
MinorRelease | Minor Release (eg. 5.0, 5.1, 6.0 - see https://www.vmware.com/support/policies/upgrade.html) |
UpdateRelease | Update Release (eg. 6.0, 6.0 U1, 6.0 U2 - https://www.vmware.com/support/policies/upgrade.html) |
Examples
Get detailed ESXi version information from all ESXi hosts connected to the vCenter Server:
PS> Get-VMHostVersion |ft -AutoSize VMHost Build Version ReleaseDate MinorRelease UpdateRelease ------ ----- ------- ----------- ------------ ------------- esx5.virten.lab 4564106 ESXi 6.5 GA 2016-11-15 ESXi 6.5 ESXi 6.5 esx4.virten.lab 4887370 ESXi 6.5a 2017-02-02 ESXi 6.5 ESXi 6.5 esx3.virten.lab 5969303 ESXi 6.5 Update 1 2017-07-27 ESXi 6.5 ESXi 6.5 U1 vesx3.virten.lab 5969303 ESXi 6.5 Update 1 2017-07-27 ESXi 6.5 ESXi 6.5 U1 vesx2.virten.lab 5969303 ESXi 6.5 Update 1 2017-07-27 ESXi 6.5 ESXi 6.5 U1 vesx1.virten.lab 5969303 ESXi 6.5 Update 1 2017-07-27 ESXi 6.5 ESXi 6.5 U1
Pipe VMHost objects to the function to get the version from a specific Cluster:
PS> Get-Cluster NUCluster |Get-VMHost |Get-VMHostVersion VMHost : esx5.virten.lab Build : 4564106 Version : ESXi 6.5 GA ReleaseDate : 2016-11-15 MinorRelease : ESXi 6.5 UpdateRelease : ESXi 6.5 VMHost : esx4.virten.lab Build : 4887370 Version : ESXi 6.5a ReleaseDate : 2017-02-02 MinorRelease : ESXi 6.5 UpdateRelease : ESXi 6.5 VMHost : esx3.virten.lab Build : 5969303 Version : ESXi 6.5 Update 1 ReleaseDate : 2017-07-27 MinorRelease : ESXi 6.5 UpdateRelease : ESXi 6.5 U1
Get-VMHostLatestVersion
The Get-VMHostLatestVersion function checks whether updates are available. The currently installed and latest version in the corresponding minor release is returned.
- No Minor Releases updates (eg. 5.5 to 6.0) are returned as the latest version.
- Updates (eg. 6.0 U1 to 6.0 U2) are returned as the latest version.
- Patches (eg. 6.0 U1 to 6.0 U1b) are returned as the latest version.
Returned object
Property | Description |
VMHost | ESXi Hostname |
currentBuild | Currently installed ESXi Build Number |
currentVersion | Currently installed Version Name used in Release Notes and https://kb.vmware.com/kb/2143832 |
currentReleaseDate | Release date of the currently installed version. |
updateAvailable | Whether an update is available (True or False |
latestBuild | Build number of the latest available patch |
latestVersion | Name of the latest available patch |
latestReleaseDate | Release date of the latest available patch |
Examples
Check a specific ESXi host for Updates. In this case, the ESXi is running on build 4564106 (GA) while an update to build 5969303 (Update 1) is available
PS> Get-VMHost esx5.virten.lab |Get-VMHostLatestVersion VMHost : esx5.virten.lab currentBuild : 4564106 currentVersion : ESXi 6.5 GA currentReleaseDate : 2016-11-15 updateAvailable : True latestBuild : 5969303 latestVersion : ESXi 6.5 Update 1 latestReleaseDate : 2017-07-27
When used without parameters or pipes, the function returns all ESXi hosts connected to the vCenter Server.
PS> Get-VMHostLatestVersion |ft -AutoSize VMHost currentBuild currentVersion currentReleaseDate updateAvailable latestBuild latestVersion latestReleaseDate ------ ------------ -------------- ------------------ --------------- ----------- ------------- ----------------- esx5.virten.lab 4564106 ESXi 6.5 GA 2016-11-15 True 5969303 ESXi 6.5 Update 1 2017-07-27 esx4.virten.lab 4887370 ESXi 6.5a 2017-02-02 True 5969303 ESXi 6.5 Update 1 2017-07-27 esx3.virten.lab 5969303 ESXi 6.5 Update 1 2017-07-27 False 5969303 ESXi 6.5 Update 1 2017-07-27 vesx3.virten.lab 5969303 ESXi 6.5 Update 1 2017-07-27 False 5969303 ESXi 6.5 Update 1 2017-07-27 vesx2.virten.lab 5969303 ESXi 6.5 Update 1 2017-07-27 False 5969303 ESXi 6.5 Update 1 2017-07-27 vesx1.virten.lab 5969303 ESXi 6.5 Update 1 2017-07-27 False 5969303 ESXi 6.5 Update 1 2017-07-27
The function also has a -verbose flag, which returns additional information like the Image Profile required to update to the latest version:
PS> Get-VMHostLatestVersion -Verbose VERBOSE: ESXi Host esx5.virten.lab (Build: 4564106): Update to ESXi 6.5 Update 1 available! (Image Profile: ESXi-6.5.0-20170702001-standard) VERBOSE: ESXi Host esx4.virten.lab (Build: 4887370): Update to ESXi 6.5 Update 1 available! (Image Profile: ESXi-6.5.0-20170702001-standard) VERBOSE: ESXi Host esx3.virten.lab (Build: 5969303): running on latest version... VERBOSE: ESXi Host vesx3.virten.lab (Build: 5969303): running on latest version... VERBOSE: ESXi Host vesx2.virten.lab (Build: 5969303): running on latest version... VERBOSE: ESXi Host vesx1.virten.lab (Build: 5969303): running on latest version... [...]
fantastic
I have downloaded the module but how to connet the Vcenter ?
I am getting the below error
PS C:\Windows\system32> Get-VMHost
Get-VMHost : The Hyper-V Management Tools could not access an expected WMI class on computer 'ASVWPSRT01'. This may indicate that the Hyper-V Platform is not installed on the computer or that the versio
the Hyper-V Platform is incompatible with these management tools.
At line:1 char:1
+ Get-VMHost
+ ~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-VMHost], VirtualizationException
+ FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.GetVMHost
hi
do you have this but for vcenters?
thanks
mark
I have a .json with vCenter Versions, but no Powershell function.
vCenter 7 has an inbuild version check so it isn't really necessary...