CREATE a VPN Connection on Windows Command Line

30,773

Solution 1

Add-VpnConnection -Name $VPNConnectionName -ServerAddress $VPNServer -TunnelType Pptp -SplitTunneling -DnsSuffix $DNSSuffix -AllUserConnection -Force

Solution 2

Use the Connection Manager Administration Kit. Then all you have to do is put it on the computer's hard drive and then you can use RASDial to connect to the vpn using the file CMAK will spit out. And if you have remote access to the computer just create a task in task scheduler to run at startup and then re-run if the connection is lost.

Sources:

CMAK Help Link: https://technet.microsoft.com/en-us/library/cc739464(v=ws.11).aspx

RASDial Help Link: https://technet.microsoft.com/en-us/library/ff859533(v=ws.11).aspx

Solution 3

Powershell can be used for this purpose. Microsoft has a complete guide about this called: Deploying VPN Connections by Using PowerShell and Group Policy

Note: Add-VpnConnection command is directly supported since windows 8.1, you may use this directly.

Share:
30,773

Related videos on Youtube

Skyler Spaeth
Author by

Skyler Spaeth

Updated on September 18, 2022

Comments

  • Skyler Spaeth
    Skyler Spaeth over 1 year

    I need to be able to CREATE a new VPN connection through the command line. I have seen things like rasdial but they are all for connecting to an existing VPN, not creating one, then joining it. The only way I know, is in the Create a VPN connection GUI. If anyone knows a way to do this out of the Windows CMD, or to make a batch file that creates, then connects to the VPN, that would be tremendously helpful. If it works in Windows 7, and Windows 10, that would be preferred, and I'm also okay with having a portable executable to complete the task if necessary. Thanks in advance!