Created
November 2, 2020 22:30
-
-
Save Swimburger/663cf785236c4d9e7294bfc1ae87716c to your computer and use it in GitHub Desktop.
A function to convert secure string to plain text as a pre-PowerShell 7 alternative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function ConvertFrom-SecureString-AsPlainText{ | |
[CmdletBinding()] | |
param ( | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipeline = $true | |
)] | |
[System.Security.SecureString] | |
$SecureString | |
) | |
$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString); | |
$PlainTextString = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr); | |
$PlainTextString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment