Created
December 24, 2018 19:18
-
-
Save giovannicandido/a940727de576578c642fdb0f2fe957b0 to your computer and use it in GitHub Desktop.
Change default network on windows to bypass proxy in cable company
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[Parameter(Mandatory=$true)] | |
[boolean]$wifiPrimary | |
) | |
# Get-NetIPInterface | |
$wifiIndex = 12 | |
$cableIndex = 10 | |
$primaryMetric = 10 | |
$secondaryMetric = 35 | |
if($wifiPrimary) { | |
Write-Host "Setup wifi as primary network" | |
Set-NetIPInterface -InterfaceIndex $wifiIndex -InterfaceMetric $primaryMetric | |
Set-NetIPInterface -InterfaceIndex $cableIndex -InterfaceMetric $secondaryMetric | |
New-NetRoute -DestinationPrefix "172.19.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.21.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.22.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.23.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.24.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.25.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.26.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.27.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.29.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.30.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.31.0.0/16" -InterfaceIndex $cableIndex | |
New-NetRoute -DestinationPrefix "172.32.0.0/16" -InterfaceIndex $cableIndex | |
}else { | |
Write-Host "Setup cable as primary network" | |
Set-NetIPInterface -InterfaceIndex $cableIndex -InterfaceMetric $primaryMetric | |
Set-NetIPInterface -InterfaceIndex $wifiIndex -InterfaceMetric $secondaryMetric | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment