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 mySuperSecretPasswordYou can remove the VPN settings with PowerShell's Remove-VpnConnection:
Remove-VpnConnection 'MyNewVpn' 2