I made a tool i can insert/start windows VPNS, i found vpns are stored in:


This tool works great, amazing even. but now i found that it doensn't save the L2TP preshared key in this phonebook.

The key can normally found in adapter settings:

enter image description here

Is there any place in windows where i can find this stored key? and would there be a way to use a command to save/add this key to windows before i make the connection?

3 Answers 3


The PSK is essentially Encoded and saved as a Password associated to the RasCredential Structure. The only other way to retrieve it would be by calling RasGetCredentials https://msdn.microsoft.com/en-us/library/windows/desktop/aa377512(v=vs.85).aspx

Another way to operate on L2TP and in general all Windows 10 VPN functionality is via the Configuration Service Provided For MDM's. Details for the VPNv2 CSP are at https://docs.microsoft.com/en-us/windows/client-management/mdm/vpnv2-csp this includes all the possible fields for a VPN Profile that you can Get or set. Additionally you can also use WMI to access these properties. For more details on that look at https://blogs.technet.microsoft.com/tip_of_the_day/2016/10/07/tip-of-the-day-configure-vpn-profiles-using-the-sccmwmi-bridge-part-2/ as well as https://docs.microsoft.com/en-us/windows/client-management/mdm/using-powershell-scripting-with-the-wmi-bridge-provider

  • That function returns asterisks.
    – user541686
    Nov 26, 2020 at 5:25

I Havent found an answer so far. starting the pbk creates an adapter but you can't really seem to change anything.

The alternative solution i found was using Powershell for this: https://technet.microsoft.com/en-us/library/jj554824(v=wps.630).aspx

Here you seem to be able to specify everything.

I Guess the program routine will be:

  • Check if vpn with same name installed: delete it
  • Create new vpn
  • Start vpn, wait until done
  • Delete vpn.

Powershell command will be like:

Add-VpnConnection test -L2tpPsk <PreSharedKeyHere>

Try Dialupass

Nirsoft Dialupass will extract the password for you as plain text: https://www.nirsoft.net/utils/dialupass.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .