add metered connection detection and option
parent
506731c2f6
commit
82598adf05
|
@ -34,6 +34,9 @@ Set WAU to run at user logon.
|
|||
.PARAMETER UpdatesInterval
|
||||
Specify the update frequency: Daily (Default), Weekly, Biweekly or Monthly.
|
||||
|
||||
.PARAMETER RunOnMetered
|
||||
Run WAU on metered connection. Default No.
|
||||
|
||||
.EXAMPLE
|
||||
.\winget-install-and-update.ps1 -Silent -DoNotUpdate
|
||||
|
||||
|
@ -251,6 +254,9 @@ function Install-WingetAutoUpdate {
|
|||
if ($UseWhiteList) {
|
||||
New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force | Out-Null
|
||||
}
|
||||
if (!$RunOnMetered) {
|
||||
New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value 1 -PropertyType DWord -Force | Out-Null
|
||||
}
|
||||
|
||||
Write-host "WAU Installation succeeded!" -ForegroundColor Green
|
||||
Start-sleep 1
|
||||
|
|
|
@ -14,7 +14,34 @@ function Test-Network {
|
|||
if ($TestNetwork) {
|
||||
|
||||
Write-Log "Connected !" "Green"
|
||||
return $true
|
||||
|
||||
#Check for metered connection
|
||||
[void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime]
|
||||
$cost = [Windows.Networking.Connectivity.NetworkInformation]::GetInternetConnectionProfile().GetConnectionCost()
|
||||
|
||||
if ($cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")){
|
||||
|
||||
Write-Log "Metered connection detected." "Yellow"
|
||||
|
||||
if ($WAUConfig.WAU_DoNotRunOnMetered -eq 1) {
|
||||
|
||||
Write-Log "WAU is configured to bypass update checking on metered connection"
|
||||
return $false
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
Write-Log "WAU is configured to force update checking on metered connection"
|
||||
return $true
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
return $true
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue