richardhicks / aovpn

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

Remove-AovpnConnection - Fails in non-english languages #8

Closed zerqent closed 3 years ago

zerqent commented 3 years ago

Hello

When removing a device/allusers-connection with Remove-AoVPNConnection the script will check to see if the users name is "nt authorithy\system", however this will fail if the language of the system is not English.

I suggest checking for the SID instead (S-1-5-18) which should be available in $CurrentPrincipal.Identities.User.Vale in the code.

Cheers!

richardhicks commented 3 years ago

Excellent suggestion. Thanks for sharing that! I'll get the code updated soon. :)

hotroot commented 3 years ago

I'd suggest you use the same code as in New-AovpnConnection.ps1:

If ($CurrentPrincipal.Identities.IsSystem -ne $true) {
        Write-Warning 'This script is not running in the SYSTEM context, as required. Exiting script.'
        Exit
    }
richardhicks commented 3 years ago

Good point! Looks like I'd already solved this issue and didn't know it. ;) I'll be updating this soon, I promise. :)

richardhicks commented 3 years ago

Ok, updated the script. Should work in all languages now. :)