Trying to create VPN script to auto config VPN on client machines

Hello all, I am in the process of writing a script to configure the VPN client on a handful (20+) client machines without having to get hands on with each machine. I have most of the logic I am just trying to figure out what else I need to get the pieces to fit together.

The first section I have basically sets up the script and all the variables used within the script

$REGPATH = "HKLM:\SYSTEM\CurrentControlSet\Services\PolicyAgent"
$REGNAME = "AssumeUDPEncapsulationContextOnSendRule"
$REGVALUE = "2"
$VPN_NAME = "VPN Friendly Name Here"
$VPN_SERVER = "123.123.123.123"
$VPN_TYPE = "L2tp"
$VPN_KEY = "supersecretkey"
$AUTHMETHOD = "MSChapv2"

So from there I can call the variables in my functions throughout the script for example

Function Set-RegKey {

    New-ItemProperty -Path $REGPATH -Name $REGNAME -Value $REGVALUE -PropertyType DWORD -Force | Out-Null

}

Basically the logic I am trying to work through is this

Gather AD Users in VPN Allow group, Find their computer, Use PSRemoting to run registry edits and VPN client setup on their machine as the domain admin, Export results of each machine configured into a csv.

Is this possible and within the reach of Powershells capabilities, or should I stick with a GPO?

Any help is much appreciated and I can provide snippets upon request.

Curious why you are making changes via the registry when there is a handy VPN command available.

You could always create a PBK file and just run a copy command to all of your computers. %ProgramData%\Microsoft\Network\Connections\Pbk\

The registry edit is to add a key to allow the vpn to work behind a NATed environment. There is a local ISP that makes use of carrier grade NATing that threw a wrench into the whole operation when they came around a few years ago and the registry key fixes the issue.

I like this idea. I’ll have to play around with it more tomorrow at the office. I would just need to change this script a bit to do just that. I only have a handful of ~300 users who need VPN access, some of which are on domain and some off.

Off domain VPN access? That sounds incredibly risky.

Its for a few select sales people, that’s how things were done before I came on board and they’re not very receptive to change just yet.