kayasax
9/30/2015 - 6:50 AM

decrypt a securestring

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