Skip to content

Instantly share code, notes, and snippets.

@kayasax
Created September 30, 2015 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kayasax/2e74da164b720943692d to your computer and use it in GitHub Desktop.
Save kayasax/2e74da164b720943692d to your computer and use it in GitHub Desktop.
decrypt a securestring
$p=read-host "password ?" -assecurestring
$Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($p)
$clearpassword = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr)
[System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($Ptr)
see more here
http://stackoverflow.com/questions/7468389/powershell-decode-system-security-securestring-to-readable-password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment