3

I've installed Azure VPN Client app and configured an Azure VPN profile. It works when I manually start it via the app's UI.

How do I initiate the connection via command line, Azure CLI or PowerShell?

Rasdial doesn't seem to work with Azure VPN Client profiles.

noseratio
  • 2,963

2 Answers2

1

Try something like this (powershell)

Start-Process -FilePath "C:\Program Files\Azure VPN Client\azurevpnclient.exe" -ArgumentList "--connect" -NoNewWindow

Turdie
  • 163
1

Azure VPN Client stores the VPN profiles in another non-system phonebook, and by default, rasdial looks in the system phone book. The phonebook is just a text file on your system that you can take a look at, located at something like $env:LOCALAPPDATA\Packages\Microsoft.AzureVpn_*\LocalState\rasphone.pbk. Then, you can run rasdial $connectionName /phonebook:$phonebookPath.

If you parse1 the phonebook file, you can get a list of all configured VPNs, and rasdial2 by itself will tell you the currently connected VPN, and the /disconnect switch (no phonebook needed) will disconnect it. That should give you all the primitives you need to fully script against the client!

LadyCailin
  • 126
  • 3