we have a meraki client vpn, which has no client vpn software. we use windows 10 built in vpn. i used powershell script below (and a batch file) to auto connect the vpn.
-
is there way to add a condition in where the attempt to connect to vpn isnt made if the computer lan/wifi is in the office and already behind the meraki?
-
also, a way to hide the credentials in the script? below it lists in plain text.
3 lastly, notify user if the vpn is not connected?
while ($true)
{
$vpnname = "YOURVPNCONNECTIONNAME"
$vpnusername = "YOURUSERNAME"
$vpnpassword = "YOURPASSWORD"
$vpn = Get-VpnConnection -AllUserConnection | where {$_.Name -eq $vpnname}
if ($vpn.ConnectionStatus -eq "Disconnected")
{
$cmd = $env:WINDIR + "\System32\rasdial.exe"
$expression = "$cmd ""$vpnname"" $vpnusername $vpnpassword"
Invoke-Expression -Command $expression
}
start-sleep -seconds 30
}