VPN Connection using Powershell without any prompts

Question:

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?

Answer:

I understand your problem connecting to Azure vNet. Here is the workaround for the same –

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.

Source:

VPN Connection using Powershell without any prompts by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply