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]
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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 MyNewVpn myUsername mySuperSecretPassword
You can remove the VPN settings with PowerShell's