Connect to a VPN using command line

I would like to connect to a VPN using command line but I saw that the only way to connect is to have the connection saved, but I would like to do it without having connection saved like that:

C:\WINDOWS\system32> rasdial [IP or Hostname]

1 Answer

I don't believe it's possible to connect with a VPN profile that isn't saved, but you can create a connection on the command line with PowerShell, using the Add-VpnConnection cmdlet specifically.

For example, to create a VPN connection, you might do something like this:

Add-VpnConnection -Name 'MyNewVpn' -ServerAddress 'vpn.example.com'

Depending on your VPN server, you may need to provide more of the named parameters.

You can then connect to it with rasdial:

rasdial MyNewVpn myUsername mySuperSecretPassword

You can remove the VPN settings with PowerShell's Remove-VpnConnection:

Remove-VpnConnection 'MyNewVpn'
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like