Closed Dmytro007 closed 2 years ago
I tested your update and it doesn't appear to be working. I have reverted to my original script for now. I will continue to test your proposed changes and see if I can get them to work, however.
Thanks!
I'm using it right now in my infrastructure and it works correct. Main purpose of such update is to make work of script similar to New-AovpnConnection.ps1. I face problem when using New-AovpnConnection.ps1 script from system context it is not able to delete user VPN Connction that is currently logon to station. Updated script works correct from user context and from system context. What doesn't work when you do testing?
It works fine when removing a device tunnel, or a user tunnel in the All Users profile, but it fails when removing an Always On VPN user tunnel configured in the user's context. I receive the following error message.
"A constructor was not found. Cannot find an appropriate constructor for type System.Security.Principal.NTAccount"
I'm running the script in the SYSTEM context when this happens. Is this working for you?
As it turns out I was running the script in a Hyper-V enhanced session so the user SID wasn't available. ;) I took your code and made a few slight changes to it and added it to the repository. Thanks so much for your contribution. Although I've never had the need to remove a user's VPN profile while running in the SYSTEM context, others might so it's good to have this script updated accordingly. Thanks again!
Removing current user's VPN profile works correctly from both the user session and the SYSTEM context. Similar to "New-AovpnConnection.ps1" script approach. New digital signature needs to be applied