Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. $vpnName = "connection mane"
  2. $vpnUsername = "user"
  3. $vpnPassword = "password `$ with escaped dollar sign"
  4. $ip = "10.10.10.51" # some site in vpn to test access to
  5.  
  6. $result = gwmi -query "SELECT * FROM Win32_PingStatus WHERE Address = '$ip'"
  7. if ($result.StatusCode -eq 0) {
  8. Write-Host "$ip is up."
  9. }
  10. else{
  11. Write-Host "$ip is down."
  12. Write-Host "Disconnecting..."
  13. rasdial.exe $vpnName /DISCONNECT
  14. Write-Host "Connecting..."
  15. rasdial.exe $vpnName $vpnUsername $vpnPassword
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement