Remove Test-NetConnection check that caused false failures
The TCP connectivity test would stall on reverse DNS lookups and exhaust its 3-retry limit even on machines with working internet. Let Invoke-WebRequest fail naturally with a real error instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
d0fa18f1c6
commit
eb1fecb886
@@ -175,14 +175,6 @@ If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
|
||||
Catch { # pass
|
||||
}
|
||||
|
||||
$X = 0
|
||||
do {
|
||||
Write-Output "Waiting for network"
|
||||
Start-Sleep -s 5
|
||||
$X += 1
|
||||
} until (($connectresult = Test-NetConnection $apilink[2] -Port 443 | Where-Object { $_.TcpTestSucceeded }) -or $X -eq 3)
|
||||
|
||||
if ($connectresult.TcpTestSucceeded -eq $true) {
|
||||
Try {
|
||||
Invoke-WebRequest -Uri $downloadlink -OutFile "$OutPath\$output"
|
||||
Start-Process -FilePath "$OutPath\$output" -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES' -Wait
|
||||
@@ -204,7 +196,4 @@ If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
|
||||
Finally {
|
||||
if (Test-Path "$OutPath\$output") { Remove-Item -Path "$OutPath\$output" -Force }
|
||||
}
|
||||
} else {
|
||||
Write-Output "Unable to connect to server"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user