VMware Cloud Community
thfarray
Contributor
Contributor
Jump to solution

PowerCli : get the expected VmWare tools version

I am trying to set a baseline to discover which VmWare tools requires upgrade, but I don't really care if I'm 1 or 2 versions behind. I think I could even work with only comparing the major version.

The Config.tools.ToolsVersionStatus or Guest.ToolsVersionStatus will let me know if I am missing an update, but not really what is the version I should be having.

Example : 

If my vm is running tools version 12.0.1, but that I only need tools version is 12.0.2, this would match my VmWare tools version expectations. But I did not find any way for me to determine in advance, what the Tools version would be after upgrading it. 

I also tried looking at https://packages.vmware.com/tools/versions, but this did not quite help me, as making the match is not really possible using PowerCli commands only.

If anyone knows how to retrieve the version that will be installed if we perfom an update-tools, this would be great.

Reply
0 Kudos
2 Solutions

Accepted Solutions
thfarray
Contributor
Contributor
Jump to solution

I already had the link, it was in my post, and anyways, this method does not work.

For Example, my VmHost build number is 21313628 and version is 7.0.3

This does not match to anything in the table.

Here is the code I used to convert this file, which did not lead me anywhere

 

 

# Step 1 : Gather the data 
$RawFile = ((Invoke-RestMethod https://packages.vmware.com/tools/versions -ErrorAction ignore) -split "`n" | ? { $_ -notmatch "^\s*#" } | ? { $_ }) -replace "`t",(" "*8)
if ($RawFile) {
	$Data = $RawFile | % {
		$_ +=  " "*100
		New-Object PsObject -property ([ordered]@{
			EsxVersion   = $_.substring(12, 20).trim() -replace 'ESX/(.).*','$1'
			EsxBuild     = $_.substring(32, 20).trim()
			ToolsVersion = $_.substring(52, 16).trim()
			ToolsBuild   = $_.substring(68).trim()
			NgcVersion   = $_.substring(0, 12).trim()
		})
	} | sort EsxVersion,EsxBuild
	$Data | Export-Csv ToolsBuild.csv
} else {
	$Data = import-csv ToolsBuild.csv
}
$Data | % { $_.EsxBuild = [int]$_.EsxBuild }
$Data = $Data  | ? { $_.EsxBuild } | group -Property EsxVersion -AsHashTable

# Step 2 : Get the correct version based on the VmHost
$MajorVersion = $Vmhost.Version -split "\." | select -First 1 
$data[$MajorVersion] | Sort-Object -Property EsxBuild | ? { ($Build - $_.EsxBuild) -ge 0 } | select -last 1 -ExpandProperty ToolsBuild

 

 

 

View solution in original post

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That table does work, it's just that not every ESXi build is in there.
When the VMware Tools version does not change with the ESXi build there is no entry.

In your case, Update 3K - build 21313628, you will have to go back to the previous entry, ESXi build 20842708, to find the corresponding VMware Tools version.

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Map the ESXi build number (obtained through Get-VMHost) in this table to find the VMware Tools version.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
thfarray
Contributor
Contributor
Jump to solution

I already had the link, it was in my post, and anyways, this method does not work.

For Example, my VmHost build number is 21313628 and version is 7.0.3

This does not match to anything in the table.

Here is the code I used to convert this file, which did not lead me anywhere

 

 

# Step 1 : Gather the data 
$RawFile = ((Invoke-RestMethod https://packages.vmware.com/tools/versions -ErrorAction ignore) -split "`n" | ? { $_ -notmatch "^\s*#" } | ? { $_ }) -replace "`t",(" "*8)
if ($RawFile) {
	$Data = $RawFile | % {
		$_ +=  " "*100
		New-Object PsObject -property ([ordered]@{
			EsxVersion   = $_.substring(12, 20).trim() -replace 'ESX/(.).*','$1'
			EsxBuild     = $_.substring(32, 20).trim()
			ToolsVersion = $_.substring(52, 16).trim()
			ToolsBuild   = $_.substring(68).trim()
			NgcVersion   = $_.substring(0, 12).trim()
		})
	} | sort EsxVersion,EsxBuild
	$Data | Export-Csv ToolsBuild.csv
} else {
	$Data = import-csv ToolsBuild.csv
}
$Data | % { $_.EsxBuild = [int]$_.EsxBuild }
$Data = $Data  | ? { $_.EsxBuild } | group -Property EsxVersion -AsHashTable

# Step 2 : Get the correct version based on the VmHost
$MajorVersion = $Vmhost.Version -split "\." | select -First 1 
$data[$MajorVersion] | Sort-Object -Property EsxBuild | ? { ($Build - $_.EsxBuild) -ge 0 } | select -last 1 -ExpandProperty ToolsBuild

 

 

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That table does work, it's just that not every ESXi build is in there.
When the VMware Tools version does not change with the ESXi build there is no entry.

In your case, Update 3K - build 21313628, you will have to go back to the previous entry, ESXi build 20842708, to find the corresponding VMware Tools version.

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
thfarray
Contributor
Contributor
Jump to solution

Finished writing the code above for anyone willing to have a try on it.

Reply
0 Kudos