Skip to content

Instantly share code, notes, and snippets.

@A1rPun
Created November 11, 2021 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save A1rPun/d946e978593856af2c93a139a68c8ea4 to your computer and use it in GitHub Desktop.
Save A1rPun/d946e978593856af2c93a139a68c8ea4 to your computer and use it in GitHub Desktop.
Azure VPN PowerShell
$connectedSleep = 59
$disconnectedSleep = 5
$currentSleep = $connectedSleep
$vpnName = "Azure VPN"
while($true) {
$value = Get-NetIPInterface | findstr -i $vpnName
if ($value -eq $null) {
$currentSleep = $disconnectedSleep
AzureVpn.exe
$wsh = New-Object -ComObject WScript.Shell
Sleep 1
$wsh.SendKeys('%A')
} else {
$currentSleep = $connectedSleep
}
Sleep $currentSleep
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment