I do not have an environment where I can test your script, but I can share how I debug scripts.
Basically I add a lot of "I got here" displays, along with variable contents or properties to verify that I am processing the data that I think I am processing.
You have that in some spots like here. I would add more before each logical step in the code.
# Add VPN profile GUID to registry
Write-Verbose "Adding VPN GUID $GUID to registry..."
I would remove all "-erroraction silentlycontinue" and " | out-null" and just let the script error out and display results. You can add those back after you get it working.
Change all write-verbose and write-warning to write-output so that you can see all messages.
I doubt that your "reg add" statement will participate in the Powershell transaction, so for initial testing I would suggest removing all references to transaction.
Are you running this script interactively or via a tool like SCCM. You might benefit from logging its activity with a transcript.