Search code examples
azureautomationwindows-10vpnazure-vpn

Connect to Azure Point to Site VPN via Script


I have a working Azure Point-to-Site VPN on Windows 10.

See this guide for instructions: https://www.starwindsoftware.com/blog/configuring-azure-point-to-site-vpn-with-windows-10

I'd like my computer to make the VPN connection on login. I know how to make Task Scheduler run a script on login. How can I make a script that will perform these two manual steps shown in the image below (mentioned in the article)? VPN Connect Dialogs


Solution

  • You can have a try on these commands working for me.

    rasphone  "vNet_GET-CMD"
    $wshell = New-Object -ComObject wscript.shell;
    $wshell.AppActivate('Network Connections')
    Sleep 2
    $wshell.SendKeys('~')
    Sleep 2
    $wshell.SendKeys('~')
    

    enter image description here