We are creating a VPN connection like this :
Add-VpnConnection -Name "TestVPN" -ServerAddress server.com -AllUserConnection -AuthenticationMethod MSChapv2 -DnsSuffix domain.net -EncryptionLevel Required -TunnelType Automatic -UseWinlogonCredential
Set-VpnConnection -Name "TestVPN" -AllUserConnection -AuthenticationMethod MSChapv2 -DnsSuffix domain.com -SplitTunneling 0 -UseWinlogonCredential 1
This succcessfully creates the connection. However now I need to automate changing the IPV4 parameters inside the vpn connection, for example :
I do this all the time for NETWORK ADAPTERS using the wmi methods of WIN32_NETWORKADAPTERCONFIGURATION :
…
$ConnectionVPN = (Get-WmiObject Win32_NetworkAdapter -filter "Name='WAN Miniport (IKEv2)'").GetRelated('Win32_NetworkAdapterConfiguration')
$ConnectionVPN.EnableStatic("x.x.x.x", "x.x.x.x")
$ConnectionVPN.SetGateways("x.x.x.x", 1)
But this doesn’t work for a VPN connection! It returns error code 97 "Interface not configurable"
How do you change IPV4 settings for a VPN connection? Thanks a lot i’m in a bind…
**EDIT**
We found out how, turns out it’s quite simple, the connection is basically in the file :
“C:\ProgramData\Microsoft\Network\Connections\Pbk\rasphone.pbk”.
So what we ended up doing:
1-Setup the connection manually, modifying all the options to your liking
2-Simply copy the .pbk file
3-When you want to deploy, simply copying the file into “C:\ProgramData\Microsoft\Network\Connections\Pbk\rasphone.pbk”
will make the connection instantly available. Removing the file removes the connection too.