Update installer.ps1
Test and wait (up to 15 seconds) to be able to connect to the server to download installer, don't try and download if we can't connect.
@@ -9,6 +9,7 @@ $rdp = rdpchange
$ping = pingchange
$auth = '"tokenchange"'
$downloadlink = 'downloadchange'
+$apilink = $downloadlink.split('/')
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@@ -47,6 +48,14 @@ If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
# pass
}
+ $X = 0
+ do {
+ Write-Output "Waiting for network"
+ Start-Sleep -s 5
+ $X += 1
+ } until(($connectreult = Test-NetConnection $apilink[2] -Port 443 | ? { $_.TcpTestSucceeded }) -or $X -eq 3)
+
+ if ($connectreult.TcpTestSucceeded -eq $true){
Try
{
Invoke-WebRequest -Uri $downloadlink -OutFile $OutPath\$output
@@ -67,4 +76,7 @@ If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
{
Remove-Item -Path $OutPath\$output
}
+ } else {
+ Write-Output "Unable to connect to server"
+ }
}
