Last active
May 14, 2025 04:29
-
-
Save JeremyTBradshaw/10c67244cf380a66b6ca0e59139cd11d to your computer and use it in GitHub Desktop.
For PowerShell 5.1 and older, convert secure strings back to plain text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertFrom-SecureStringToPlainText ([System.Security.SecureString]$SecureString) { | |
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto( | |
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString) | |
) | |
} | |
New-Alias -Name s2p -Value ConvertFrom-SecureStringToPlainText |
Very cool, thanks!
Thank you very much, this working code is very rare!
Glad you found it. I keep it in my daily driver PS profile, comes in handy often.
Very nice, thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I learned this trick from here: https://techibee.com/powershell/convert-system-security-securestring-to-plain-text-using-powershell/2599