PowerShell - Decode System.Security.SecureString to readable password

后端 未结 4 1763
既然无缘
既然无缘 2020-11-29 07:09

I want to decode the password from a System.Security.SecureString to a readable password.

$password = convertto-securestring \"TestPassword\" -asplaintext -f         


        
4条回答
  •  天涯浪人
    2020-11-29 08:10

    The details are explained http://blogs.msdn.com/b/besidethepoint/archive/2010/09/21/decrypt-secure-strings-in-powershell.aspx

    and I have yet another slightly different way of doing it.

    $pass=convertto-securestring "P@ssw0rd" -asplaintext -force  | ConvertFrom-SecureString
    [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR( (ConvertTo-SecureString $pass) ))
    

    P@ssw0rd

提交回复
热议问题