Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

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
}
share|improve this question
    
What do you want to pass the script? a subnet and an address? –  soandos Aug 4 '13 at 4:12
    
I want to insert IP range so instead of 10.20.30.40 in the scrip above, I want to insert all IPs between 10.0.0.0 to 10.255.255.255. –  dreamerman Aug 4 '13 at 7:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.