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:
uhlwoogi
2026-04-21 16:30:56 +00:00
co-authored by Claude Sonnet 4.6
parent d0fa18f1c6
commit eb1fecb886
+17 -28
View File
@@ -175,36 +175,25 @@ If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
Catch { # pass
}
$X = 0
do {
Write-Output "Waiting for network"
Try {
Invoke-WebRequest -Uri $downloadlink -OutFile "$OutPath\$output"
Start-Process -FilePath "$OutPath\$output" -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES' -Wait
Write-Host "Extracting..."
Start-Sleep -s 5
$X += 1
} until (($connectresult = Test-NetConnection $apilink[2] -Port 443 | Where-Object { $_.TcpTestSucceeded }) -or $X -eq 3)
Start-Process -FilePath "C:\Program Files\TacticalAgent\tacticalrmm.exe" -ArgumentList $installArgs -Wait
if ($connectresult.TcpTestSucceeded -eq $true) {
Try {
Invoke-WebRequest -Uri $downloadlink -OutFile "$OutPath\$output"
Start-Process -FilePath "$OutPath\$output" -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES' -Wait
Write-Host "Extracting..."
Start-Sleep -s 5
Start-Process -FilePath "C:\Program Files\TacticalAgent\tacticalrmm.exe" -ArgumentList $installArgs -Wait
# ── Install RustDesk after Tactical RMM ──
Install-RustDesk
# ── Install RustDesk after Tactical RMM ──
Install-RustDesk
exit 0
}
Catch {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-Error -Message "$ErrorMessage $FailedItem"
exit 1
}
Finally {
if (Test-Path "$OutPath\$output") { Remove-Item -Path "$OutPath\$output" -Force }
}
} else {
Write-Output "Unable to connect to server"
exit 0
}
Catch {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-Error -Message "$ErrorMessage $FailedItem"
exit 1
}
Finally {
if (Test-Path "$OutPath\$output") { Remove-Item -Path "$OutPath\$output" -Force }
}
}