commit
c0ef832803
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue