Merge pull request #477 from andreasbrett/patch-2

Fix network test failing - catch IWR exceptions
pull/485/head
Romain 2023-11-12 20:24:48 +01:00 committed by GitHub
commit 2a8305d694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -17,11 +17,15 @@ function Test-Network {
$ncsiHost = "www.msftconnecttest.com" $ncsiHost = "www.msftconnecttest.com"
$ncsiPath = "connecttest.txt" $ncsiPath = "connecttest.txt"
$ncsiContent = "Microsoft Connect Test" $ncsiContent = "Microsoft Connect Test"
} finally {
$ncsiResponse = Invoke-WebRequest -Uri "http://$($ncsiHost)/$($ncsiPath)" -UseBasicParsing
} }
if (($ncsiResponse.StatusCode -eq 200) -and ($ncsiResponse.content -eq $ncsiContent)) { try {
$ncsiResponse = Invoke-WebRequest -Uri "http://$($ncsiHost)/$($ncsiPath)" -UseBasicParsing
} catch {
$ncsiResponse = $false
}
if (($ncsiResponse) -and ($ncsiResponse.StatusCode -eq 200) -and ($ncsiResponse.content -eq $ncsiContent)) {
Write-ToLog "Connected !" "Green" Write-ToLog "Connected !" "Green"
#Check for metered connection #Check for metered connection