Keep-alive script for Windows VPN connections

on
$ServerName = "192.168.40.1"

##### Script Starts Here ######  
foreach ($Server in $ServerName) { 
 
        if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {  
         
            write-Host "$Server is alive and Pinging " -ForegroundColor Green 
         
                    } else 
                     
                    {
          Write-Host "$Server is down."
          Write-Host "Disconnecting..."
          rasdial.exe "Woodside" /DISCONNECT
          Write-Host "Connecting..."
          rasdial.exe "Woodside" user vpnpassword
          }    
         
} 

 

Leave a Reply

Your email address will not be published. Required fields are marked *