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