Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save cmsp-marufe/9267eefc818660f34d220f862a6a1e62 to your computer and use it in GitHub Desktop.

Select an option

Save cmsp-marufe/9267eefc818660f34d220f862a6a1e62 to your computer and use it in GitHub Desktop.
For PowerShell 5.1 and older, convert secure strings back to plain text
function ConvertFrom-SecureStringToPlainText ([System.Security.SecureString]$SecureString) {
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto(
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)
)
}
@cmsp-marufe
Copy link
Author

I am using this particular function in a PowerShell Module, and re-importing the module for testing causes the 'alias' command in Jeremy's version to throw an error on each subsequent run, so I removed that last line from my fork here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment