# # Run on the same computer, under the same user, who has saved OpenVPN password. # Open PowerShell, as current user, not administrator, execute command # Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted # , then run this script as .\OpenVPNRecoverSavedPassword.ps1 # Add-Type -AssemblyName System.Security $keys = Get-ChildItem "HKCU:\Software\OpenVPN-GUI\configs" $items = $keys | ForEach-Object {Get-ItemProperty $_.PsPath} foreach ($item in $items) { Write-Host ($item.'PSChildName') $username=$encryptedbytes=$item.'username' Write-Host ([System.Text.Encoding]::Unicode.GetString($username)) $encryptedbytes=$item.'auth-data' $entropy=$item.'entropy' $entropy=$entropy[0..(($entropy.Length)-2)] $decryptedbytes = [System.Security.Cryptography.ProtectedData]::Unprotect( $encryptedBytes, $entropy, [System.Security.Cryptography.DataProtectionScope]::CurrentUser) Write-Host ([System.Text.Encoding]::Unicode.GetString($decryptedbytes)) Write-Host (' ') }