Merge pull request #476 from andreasbrett/patch-2

Fix network test failing
pull/477/head^2
Romain 2023-11-12 20:00:54 +01:00 committed by GitHub
commit c0ef832803
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 5 deletions

View File

@ -9,11 +9,19 @@ function Test-Network {
Write-ToLog "Checking internet connection..." "Yellow" Write-ToLog "Checking internet connection..." "Yellow"
While ($timeout -lt 1800) { While ($timeout -lt 1800) {
$URLtoTest = "https://raw.githubusercontent.com/Romanitho/Winget-AutoUpdate/main/LICENSE" try {
$URLcontent = ((Invoke-WebRequest -URI $URLtoTest -UseBasicParsing).content) $ncsiHost = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" -Name ActiveWebProbeHost
$ncsiPath = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" -Name ActiveWebProbePath
if ($URLcontent -like "*MIT License*") { $ncsiContent = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet" -Name ActiveWebProbeContent
} catch {
$ncsiHost = "www.msftconnecttest.com"
$ncsiPath = "connecttest.txt"
$ncsiContent = "Microsoft Connect Test"
} finally {
$ncsiResponse = Invoke-WebRequest -Uri "http://$($ncsiHost)/$($ncsiPath)" -UseBasicParsing
}
if (($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