Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $vpnName = "connection mane"
- $vpnUsername = "user"
- $vpnPassword = "password `$ with escaped dollar sign"
- $ip = "10.10.10.51" # some site in vpn to test access to
- $result = gwmi -query "SELECT * FROM Win32_PingStatus WHERE Address = '$ip'"
- if ($result.StatusCode -eq 0) {
- Write-Host "$ip is up."
- }
- else{
- Write-Host "$ip is down."
- Write-Host "Disconnecting..."
- rasdial.exe $vpnName /DISCONNECT
- Write-Host "Connecting..."
- rasdial.exe $vpnName $vpnUsername $vpnPassword
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement