2

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.

4
  • In Azure CLI, you might be looking for az network vpn-connection create.
    – harrymc
    Commented Sep 14, 2023 at 19:39
  • @harrymc isn't it for creating a new connection? I need to establish (activate) an existing confection.
    – noseratio
    Commented Sep 15, 2023 at 12:45
  • That's why I'm asking - there are parameters that suggest that it establishes a connection to an existing VPN.
    – harrymc
    Commented Sep 15, 2023 at 12:59
  • I think I've found the answer: stackoverflow.com/q/39638726
    – noseratio
    Commented Sep 18, 2023 at 0:58

2 Answers 2

1

Try something like this (powershell)

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

2
  • This doesn't work for me, although I have multiple connections. Where did you get this info? Are there more commandline switches documented somewhere?
    – LadyCailin
    Commented 2 days ago
  • Actually, this isn't even the right location, the client is installed as a Windows Store App, so it isn't directly in Program Files. Where do you get it so that it's installed as a standalone app?
    – LadyCailin
    Commented 2 days ago
0

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!

New contributor
LadyCailin is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .