Hi,
I have tinkered lightly with powershell and I'm finally really trying to do something useful with it. My users are a "challenge" to say the least and cannot be relied upon to actually connect the openvpn client without being yelled at.
I'd like to find a way to execute a powershell script through a scheduled task at startup that first checks to see there is a working internet connection, if there isn't, wait 10 minutes and start over, if there is a working connection, see if the vpn server
can be contacted, if it can, wait 10 minutes and start over, if not, then execute a batch file silently that starts the vpn.
I created a batch to exe and it runs silently and starts the vpn properly if run from command line
I'm stuck on the how to "wait 10 minutes and start over" in the nested if statements or even if my nested if statements are correct. Here is what I have so far, any input or help is appreciated. Hopefully I'm posting this in the right
place.
#check if computer has internet connection
if (Test-Connection -computer 8.8.8.8 -quiet)
{
#if 8.8.8.8 is true then test if vpn is up
if (!(Test-Connection -computer 10.1.0.6 -quiet))
{
# if true wait 10 minutes and run again
}
Else
{Set-Location "C:\Program Files (x86)\OpenVPN Technologies\OpenVPN Client\core\"
Start-Process tscvpnstart.exe
}
}
Else
{
#wait 10 minutes and run again
}