Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JeremyTBradshaw/10c67244cf380a66b6ca0e59139cd11d to your computer and use it in GitHub Desktop.
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
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
@JeremyTBradshaw
Copy link
Author

@cmsp-marufe
Copy link

Very cool, thanks!

@fededim
Copy link

fededim commented Feb 26, 2025

Thank you very much, this working code is very rare!

@JeremyTBradshaw
Copy link
Author

Glad you found it. I keep it in my daily driver PS profile, comes in handy often.

@MisterH
Copy link

MisterH commented Mar 13, 2025

Very nice, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment