richardhicks / aovpn

PowerShell scripts and sample ProfileXML files for configuring Windows 10 Always On VPN
MIT License
158 stars 83 forks source link

Update-Rasphone.ps1 fails for user profile installed with Config Manager #4

Closed Rockavina closed 4 years ago

Rockavina commented 4 years ago

Config Manager install package runs in system context for the user profile, so pbk path will default to system path instead of user path.

I've solved this by adding RasphonePath as an optional parameter and passing this from the profile install script, which already pulls the username from wmi.

richardhicks commented 4 years ago

Thanks! Can you share your code?

Rockavina commented 4 years ago

Sure, can't really do a pull request since you've signed the source scripts, so I'll just share here. Basically it'll work like before, but you can override the defaults with a parameter

Added parameter: [string]$RasphonePath Added comment help for RasphonePath

Modified RasphonePath definition:

# // Define rasphone.pbk file path
if (-not $RasphonePath -and $AllUserConnection) {

    $RasphonePath = 'C:\ProgramData\Microsoft\Network\Connections\Pbk\rasphone.pbk'

}

Elseif(-not $RasphonePath) {

    $RasphonePath = "$env:appdata\Microsoft\Network\Connections\Pbk\rasphone.pbk"

}

Then I can pass the path from calling script, e.g:

$RasphonePath = "C:\Users\user1\AppData\Roaming\microsoft\network\Connections\Pbk\rasphone.pbk"

.\Update-Rasphone.ps1 -RasphonePath $RasphonePath -ProfileName $ProfileName -InterfaceMetric 10
richardhicks commented 4 years ago

Thanks! I'll incorporate this in to the next update for sure. :)

richardhicks commented 4 years ago

Thanks again for the heads up on this. I'll be uploading a new script shortly.