Reputation: 51
I am trying to connect with a VPN on my server machine using this powershell command :
rasphone.exe -d MyVPN
MyVPN is the name of network i want to connect.
It opens up a windows azure virtual network dialog which prompts for user confirmation. I am manually able to connect with VPN by clicking confirm button but I want to do this without any prompts. I tried -confirm parameters but it is unavailable for rasphone command. Any suggestions?
Upvotes: 5
Views: 2677
Reputation: 2206
I understand your problem connecting to Azure vNet. Here is the workaround for the same -
rasphone "YOURVPNNAME"
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('Network Connections')
Sleep 2
$wshell.SendKeys('~')
Sleep 3
$wshell.SendKeys('~')
You get the prompt when you call rasdial. Next you make the network connection window as the active window. You hit enter by sending $wshell.SendKeys('~')
here. Sleep is used so that you get ample time as the previous enter again pops up a window for confirmation where again you hit the default selection.
Hope it works for you as well.
Upvotes: 2