Is there a way to script or export a VPN connection set up with the built in Windows 10 method?
Specifically adding in the DNS suffix and security settings.
Is there a way to script or export a VPN connection set up with the built in Windows 10 method?
Specifically adding in the DNS suffix and security settings.
You can edit rasphone.pbk directly with PowerShell and change most settings. The caveat is the connection needs to be created first.
This is the part of our VPN connection creation script that enables DNS registration via rasphone.pbk.
$RASPhoneBook = “C:\ProgramData\Microsoft\Network\Connections\Pbk\rasphone.pbk”
(Get-Content $RASPhoneBook) -Replace ‘IpDnsFlags=0’, ‘IpDnsFlags=1’ | Set-Content $RASPhoneBook
Powershell Add-Vpnconnection will do most of the setup.
Not sure about DNS though.
So i did try this, but then i encountered the issue that if one person gets 1 VPN, and a second person gets 2 VPNs, then this method won’t work.
I would need to have quite a bit of pre made .pbks potentially in my environment.
Do you mean two VPN’s with two different suffix’s? Yeah that would be a problem, but you could put some logic into the PowerShell to add a specific suffix depending on the VPN name for instance.
You can add the suffix when creating a connection via PowerShell.
Add-VpnConnection -AllUserConnection -Name “VPN” -ServerAddress ‘vpn.domain.com’ -TunnelType L2tp -DNSSuffix ‘test.domain.com’ -EncryptionLevel Optional -AuthenticationMethod PAP -L2tpPsk ‘PSK’ -Force –PassThru