Created
April 26, 2020 23:45
-
-
Save BluBb-mADe/793ee776a4b38b1d8771f639d1d9e0b0 to your computer and use it in GitHub Desktop.
Quickly toggle windows 10 vpn connection on and off and enable or disable ipv6 at the same time
This file contains 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
if(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
$arguments = "& '" + $myinvocation.mycommand.definition + "'" | |
Start-Process powershell -Verb runAs -ArgumentList $arguments | |
break | |
} | |
$con_state = (rasdial) | Out-String | |
if($con_state.StartsWith("Connected to")) { | |
echo "Disconnecting from vpn..." | |
rasdial /disconnect | |
Enable-NetAdapterBinding -InterfaceAlias "Ethernet" -ComponentID ms_tcpip6 | |
} else { | |
echo "Connecting to vpn..." | |
Disable-NetAdapterBinding -InterfaceAlias "Ethernet" -ComponentID ms_tcpip6 | |
rasdial "server vpn" | |
} | |
echo "Done" | |
Start-Sleep -s 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment