Skip to content

Instantly share code, notes, and snippets.

@DanielSmon
Last active July 11, 2022 23:52
Show Gist options
  • Save DanielSmon/ea5d392072f4be79cb506035a49d1d65 to your computer and use it in GitHub Desktop.
Save DanielSmon/ea5d392072f4be79cb506035a49d1d65 to your computer and use it in GitHub Desktop.
Function Decrypt-SecureString {
param(
[Parameter(ValueFromPipeline=$true,Mandatory=$true,Position=0)]
[System.Security.SecureString]
$sstr
)
$marshal = [System.Runtime.InteropServices.Marshal]
$ptr = $marshal::SecureStringToBSTR( $sstr )
$str = $marshal::PtrToStringBSTR( $ptr )
$marshal::ZeroFreeBSTR( $ptr )
$str
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment