This article explains how to automatically workaround the issue where the first attempt to install VMware tools on a new Server2016 system fails to install the VMWare Tools (VMTools) service.
Explanation
I have been setting up a deployment pipeline for a number of system images, including Server 2016, using Ansible and Packer. I noticed that whenever deploying a new Server 2016 VM on one of my clusters, the scripted install of VMWare Tools (using setup64.exe) ‘completed’ without installing the VMWare Tools Service. As a result, my deployment failed, as Packer needs VMWare tools to post the deployed VM’s DHCP address to vSphere so that it can connect over WinRM.
This issue may to be related to: https://kb.vmware.com/s/article/55798
Environment
- Server 2016 Datacenter ISO, recently downloaded from Microsoft
- Desktop Experience and Core installations both experience the issue
- VMWare Tools for Windows ISO (v. 10.3.10-12406962)
- Saw the same behavior with v. 10.2.1-8267844
- ESXi 6.5, build 9298722 Cluster
Attempted Fixes
Manual VC Redistributable install
After reading the KB article above, I tried to first install the VC Redistributable 2017 package ahead of the vmware tools install. However, installing the VC Redist 2017 package apparently wasn’t what the VMWare tools installer was looking for. The VMWare Tools installer would end up installing a VC Redist 2008 package during it’s install, so it appears the versioning was off.
Silent install of the VC Redist 2017 package, for reference:
Powershell: Start-Process "vcredist_x64.exe" -ArgumentList '/install /passive /norestart' -Wait CMD: & .\vcredist_x64.exe /install /passive /norestart
I then shifted to using the VC Redist 2008 package, but I still experienced the issue with the VMWare Tools service not being installed on the first install attempt.
Silent install of the VC Redist 2008 package, for reference:
Powershell: Start-Process "vcredist_x64_2008-9.0.30729.6161.exe" -ArgumentList '/qb' -Wait CMD: & .\vcredist_x64_2008-9.0.30729.6161.exe /qb
VMWare Tools Install Script with Re-Install Logic
The only other resolution was to manually reinstall VMWare Tools, but I needed this to be done during an unattended deployment of Server2016. As a result, I updated my VMWare Tools installation script to include logic to reinstall VMWare Tools if the VMTools service didn’t come up after the first install. Note that VMWare Tools is only reinstalled if the first attempt failed:
#Set the current working directory to whichever drive corresponds to the mounted VMWare Tools installation ISO Set-Location d: #Install VMWare Tools Start-Process "setup64.exe" -ArgumentList '/s /v "/qb REBOOT=R"' -Wait #After the installation is finished, check to see if the 'VMTools' service enters the 'Running' state every 2 seconds for 10 seconds $Running = $false $iRepeat = 0 while (!$Running -and $iRepeat -lt 5) { Start-Sleep -s 2 $Service = Get-Service "VMTools" -ErrorAction SilentlyContinue $Servicestatus = $Service.Status if ($ServiceStatus -notlike "Running") { $iRepeat++ } else { $Running = $true } } #If the service never enters the 'Running' state, re-install VMWare Tools if (!$Running) { #Uninstall VMWare Tools Start-Process "setup64.exe" -ArgumentList '/s /c' -Wait #Install VMWare Tools Start-Process "setup64.exe" -ArgumentList '/s /v "/qb REBOOT=R"' -Wait #Wait again for the VMTools service to start $iRepeat = 0 while (!$Running -and $iRepeat -lt 5) { Start-Sleep -s 2 $Service = Get-Service "VMTools" -ErrorAction SilentlyContinue $ServiceStatus = $Service.Status if ($ServiceStatus -notlike "Running") { $iRepeat++ } else { $Running = $true } } #If after the reinstall, the service is still not running, this is a failed deployment. if (!$Running) { Write-Host -ForegroundColor Red "VMWare Tools are still not installed correctly. This is a failed deployment." Pause } }