简体   繁体   English

使用 Powershell 的 VPN 连接没有任何提示

[英]VPN Connection using Powershell without any prompts

I am trying to connect with a VPN on my server machine using this powershell command :我正在尝试使用此 powershell 命令在我的服务器计算机上连接 VPN:

rasphone.exe -d MyVPN rasphone.exe -d MyVPN

MyVPN is the name of network i want to connect. MyVPN是我要连接的网络名称。

It opens up a windows azure virtual network dialog which prompts for user confirmation.它会打开一个 windows azure 虚拟网络对话框,提示用户确认。 I am manually able to connect with VPN by clicking confirm button but I want to do this without any prompts.我可以通过单击确认按钮手动连接 VPN,但我想在没有任何提示的情况下执行此操作。 I tried -confirm parameters but it is unavailable for rasphone command.我试过 -confirm 参数,但它不适用于 rasphone 命令。 Any suggestions?有什么建议吗?

I understand your problem connecting to Azure vNet.我了解您连接到 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.当您调用 rasdial 时,您会收到提示。 Next you make the network connection window as the active window.接下来,您将网络连接窗口设为活动窗口。 You hit enter by sending $wshell.SendKeys('~') here.您可以通过在此处发送$wshell.SendKeys('~')$wshell.SendKeys('~') 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.希望它也适用于您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM