Skip to content

Commit

Permalink
Merge pull request #1 from RyanBijkerk/master
Browse files Browse the repository at this point in the history
Update to ensure the latest VMware tools is downloaded based on the available version
  • Loading branch information
tvories committed Apr 8, 2021
2 parents dd4079c + 7dbb1e8 commit 8015db7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/Install-VMWareTools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ if([int]$wmi_operatingsystem.version.Substring(0,1) -le 6) { # Server 2008
$url = 'https://packages.vmware.com/tools/releases/10.2.5/windows/x64/VMware-tools-10.2.5-8068406-x86_64.exe'
} else { # Anything above 2008
Write-Verbose "Latest Tools selected (not 2008R2)"
$url = 'https://packages.vmware.com/tools/releases/latest/windows/x64/VMware-tools-11.1.0-16036546-x86_64.exe'

$content = Invoke-WebRequest -Uri "https://packages.vmware.com/tools/releases/latest/windows/x64/"
$version = ($content.Links | Where-Object {$_.href -like "VMware-tools*" }).href

$url = "https://packages.vmware.com/tools/releases/latest/windows/x64/$($version)"
}

# install vmware tools
Expand All @@ -17,7 +21,7 @@ $timeout = 30 # Timeout in minutes for it to fail this job
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url,$path)
$args = '/s /v /qn reboot=r'
Write-Verbose "Tools download successful. Install starting."
Write-Verbose "Tools download successful. Install starting."
$timer = [Diagnostics.Stopwatch]::StartNew()
Start-Process -FilePath $path -ArgumentList $args -PassThru

Expand All @@ -37,7 +41,7 @@ $toolswait = $true
While ($toolswait){
if(!(Test-VMInstall)){
if($timer.Elaspsed.TotalMinutes -gt $timeout) {
Write-Verbose "Tools not detected within timeout. Failing job."
Write-Verbose "Tools not detected within timeout. Failing job."
Exit 1
}
Write-Verbose "Tools not detected yet."
Expand Down

0 comments on commit 8015db7

Please sign in to comment.