Skip to content

Instantly share code, notes, and snippets.

@turboBasic
Created July 21, 2018 20:04
Show Gist options
  • Save turboBasic/ffdd6d7a37221b754adba103cb294157 to your computer and use it in GitHub Desktop.
Save turboBasic/ffdd6d7a37221b754adba103cb294157 to your computer and use it in GitHub Desktop.
[Get-DecryptedSecureString] :: Decrypts secure strings eg. from [System.Management.Automation.PSCredential], Get-Credential etc.
function Get-DecryptedSecureString( [System.Security.SecureString] $secureString )
{
return [System.Runtime.InteropServices.Marshal]::PtrToStringUni(
[System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode(
$secureString
))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment