Closed
Description
Description
The issue happens in PowerShell 7.* in Linux/MacOS. The root cause is there is breaking change for the API PtrToStringAuto.
To workaround the issue, please follow the sample below to decrpyt secure string.
$psTxt = . "$PSScriptRoot/../utils/Unprotect-SecureString.ps1" $PSBoundParameters['Password']
Source code of Unprotect-SecureSting.ps1
#This script converts securestring to plaintext
param(
[Parameter(Mandatory, ValueFromPipeline)]
[System.Security.SecureString]
${SecureString}
)
$ssPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)
try {
$plaintext = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ssPtr)
} finally {
[System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ssPtr)
}
return $plaintext