Created
March 18, 2020 20:42
-
-
Save SeidChr/43a3252ed9a1c50aad7cacccc6997835 to your computer and use it in GitHub Desktop.
windows based vpn automatic reconnect
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($vpnName) | |
rasdial $vpnName /disconnect |
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($vpnName) | |
while($true) { | |
# get the connection again, otherwise the status is not refreshed | |
$vpn = Get-VpnConnection -Name $vpnName | |
Write-Host $vpn.ConnectionStatus | |
if ($vpn.ConnectionStatus -eq "Disconnected") { | |
rasdial $vpnName | |
# double the sleep time after a connect | |
Start-Sleep -Seconds 30 | |
} | |
Start-Sleep -Seconds 30 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment