Skip to content

Instantly share code, notes, and snippets.

@BluBb-mADe
Created April 26, 2020 23:45
Show Gist options
  • Save BluBb-mADe/793ee776a4b38b1d8771f639d1d9e0b0 to your computer and use it in GitHub Desktop.
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
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