I am looking to use powershell and task scheduler in windows 7 ultimate 32 bit to redial vpn should the vpn connection drops. I found a scrip ( http://blog.degree.no/2011/10/permanent-vpn-connection-in-windows/ ) but it only have one IP address. What I need is a range of IP address like 10.0.0.0/16 because of the way my vpn assigns IP addresses. Can anyone help me out please?
Create c:\pn.ps1 and add the following:
$ip = "10.20.30.40"
$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 DegreeVPN /DISCONNECT
Write-Host "Connecting..."
rasdial.exe DegreeVPN vpnUsername vpnPassword12345
}
Create c:\pn.ps1 and add the following:
$ip = "10.20.30.40"
$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 DegreeVPN /DISCONNECT
Write-Host "Connecting..."
rasdial.exe DegreeVPN vpnUsername vpnPassword12345
}