For anybody who needs to decrypt SAM credentials (including passwords) you can use the following PowerShell script. Create a new Application template with one PowerShell component. Run this script in test mode against any node, local execution. Cycle through your SAM credentials to export them to the text file. There is no need to actually deploy this as a real APM.
Decrypt Credential |
---|
Function SecureStringToString($Value) { [System.IntPtr] $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Value); try { [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($BSTR); } finally { [System.Runtime.InteropServices.Marshal]::FreeBSTR($BSTR); } } $cred = Get-Credential -credential ${CREDENTIAL} [string] $username = $cred.Username [string] $password = SecureStringToString $cred.Password [string] $PlainTextCredential = ($username + ", " + $password) Add-Content -Path C:\Credentials.txt -Value $PlainTextCredential Write-Host "Message: " $PlainTextCredential Write-Host "Statistic: 0" Exit 0 |