$VpnName = "ИМЯ_VPN_СОЕДИНЕНИЯ"
$gateway = "IP_СЕРВЕРА"
$psk = "КЛЮЧ-IPSEC"
$regp = 'HKLM:\SYSTEM\CurrentControlSet\Services\PolicyAgent' #if VPN server is behind NAT, otherwise comment out this line.
#add l2tp vpn
Add-VpnConnection -Name $VpnName -ServerAddress $gateway -TunnelType L2tp -AuthenticationMethod MSChapv2 -EncryptionLevel Optional -L2tpPsk $psk -Force -AllUserConnection -RememberCredential -SplitTunneling
New-ItemProperty -Path $regp -Name AssumeUDPEncapsulationContextOnSendRule -Value 2 -PropertyType 'DWORD' -Force