none
Get windows VPN adapters with -AllUserConnections parameter RRS feed

  • Question

  • I need to get all VPN adapters programatically with C#

    It works with rasphone.pbk

    Like in this answer: https://stackoverflow.com/questions/25610379/get-windows-vpn-interfaces-in-c-sharp

    Problem i found is when you create VPN from powershell with -AllUserConnections (all users can use vpn form login screen). It's not saved in that rasphone.pbk
    The connection is saved somewhere in global phonebook due to msdocs. I was trying but was not able to find it.

    PS command i use to add VPN:

        Add-VpnConnection -Name " + VPNName + " -ServerAddres " + serveraddress + " -TunnelType L2tp -L2tpPsk " + L2tpPSK + " -Force -AuthenticationMethod MSChapv2 -EncryptionLevel Optional -AllUserConnection

    Any idea where could it be? Or any idea how to check for VPN adapters with this parameter? Maybe with WMI but could not find adapter there either.

    • Edited by Johny V Sunday, December 22, 2019 6:26 PM
    Sunday, December 22, 2019 6:26 PM

All replies

  • Hi Johny V,

    Thank you for posting here.

    If you are using a VPN service provided by Windows, the corresponding configuration information will be stored in rasphone.pbk. 

    However, if you are using a third-party VPN software, the storage location of the corresponding information depends on the software provider, and you'd better confirm this information with them.

    The following link is about managing VPN using C # code.

    How can I programmatically connect to a VPN?

    C# code to maintain VPN connection programatically.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Hope this could be helpful.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Monday, December 23, 2019 6:25 AM
  • Hi Johny V,

    Thank you for posting here.

    If you are using a VPN service provided by Windows, the corresponding configuration information will be stored in rasphone.pbk. 

    However, if you are using a third-party VPN software, the storage location of the corresponding information depends on the software provider, and you'd better confirm this information with them.

    The following link is about managing VPN using C # code.

    How can I programmatically connect to a VPN?

    C# code to maintain VPN connection programatically.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Hope this could be helpful.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    How can i use third party software when im creating VPN connection with powershell? I'm using windows 10 VPN and when you create it with -AllUserConnection parameter in powershell it does not show in rasphone.pbk but you still can see it in VPN adapters!


    • Edited by Johny V Monday, December 23, 2019 5:11 PM
    Monday, December 23, 2019 5:10 PM
  • I need to get all VPN adapters programatically with C#

    It works with rasphone.pbk

    Like in this answer: https://stackoverflow.com/questions/25610379/get-windows-vpn-interfaces-in-c-sharp

    Problem i found is when you create VPN from powershell with -AllUserConnections (all users can use vpn form login screen). It's not saved in that rasphone.pbk
    The connection is saved somewhere in global phonebook due to msdocs. I was trying but was not able to find it.

    PS command i use to add VPN:

        Add-VpnConnection -Name " + VPNName + " -ServerAddres " + serveraddress + " -TunnelType L2tp -L2tpPsk " + L2tpPSK + " -Force -AuthenticationMethod MSChapv2 -EncryptionLevel Optional -AllUserConnection

    Any idea where could it be? Or any idea how to check for VPN adapters with this parameter? Maybe with WMI but could not find adapter there either.

    Found answer. global phonebook is in here:

    C:\ProgramData\Microsoft\Network\Connections\Pbk

    Tuesday, December 24, 2019 9:01 AM
  • Hi Johny V,

    I'm glad to hear that your issue has been resolved.

    You can click "Mark as answer" in your own reply, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 25, 2019 5:36 AM