To set up a new VPN connection:
1. Open VPN settings:
Press Win + R, type ms-settings:network-vpn and press Enter.
2. Click "Add a VPN connection".
Set "VPN provider" to "Windows (built-in)",
Set "Connection name" to "GPN",
Set "VPN type" to "L2TP/IPsec with pre-shared key".
Fill rest of the fields with the data obtained in the user credentials dialogue. Where:
Server name or address: VPN server
Pre-shared key: Shared secret
User name: Login
Password: Password
Click "Save".
3. Open Windows PowerShell:
- Click Start (or press Win), type PowerShell, and then click Windows PowerShell.
4. Run the following command to check connection properties:
Get-VpnConnection -Name "GPN" -erroraction 'silentlycontinue'; Get-VpnConnection -AllUserConnection -Name "GPN" -erroraction 'silentlycontinue'
5. Check the "AllUserConnection" property in the output of the previous command. It indicates whether the VPN connection is in the global (machine) or local (user) phone book. If "True", run:
Set-VpnConnection -Name "GPN" -EncryptionLevel "Optional" -AuthenticationMethod CHAP, MSCHAPv2 -SplitTunneling $True -AllUserConnection -PassThru
Otherwise run:
Set-VpnConnection -Name "GPN" -EncryptionLevel "Optional" -AuthenticationMethod CHAP, MSCHAPv2 -SplitTunneling $True -PassThru
The command configures additional parameters like "AuthenticationMethod" and "SplitTunneling". The first version of the command has " -AllUserConnection" parameter which indicates that the VPN connection specified is in the global phone book.
6. Finally, add the route for the VPN connection by running:
Add-VpnConnectionRoute -ConnectionName "GPN" -DestinationPrefix "10.0.0.0/8"
You can now connect to the VPN:
By choosing "GPN" and clicking "Connect" next to it in the VPN section of Windows Settings (Win + R, ms-settings:network-vpn, Enter);
By clicking the network icon in the system tray, choosing "GPN" and clicking "Connect" next to it;
By running "rasdial GPN" in a PowerShell window.