$ss = ConvertTo-SecureString -String 'TestString' -AsPlainText -Force
$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($ss)
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)
Should return 'TestString'
On PS 7 on Linux:
Returns 'T' - Incorrect Behavior.

On PS 7 on Windows 10:
Returns 'TestString' - Correct Behavior.

Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Linux 4.4.0-19582-Microsoft #1001-Microsoft Thu Mar 06 16:40:00 PST 2020
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This is a minor issue as the above code can usually be replaced with ConvertFrom-SecureString on PS 7/PS Core 6, but not on PS 5.1.
This is a duplicate of #12114; for a summary, see https://github.com/PowerShell/PowerShell/issues/12114#issuecomment-598347725
Most helpful comment
This is a duplicate of #12114; for a summary, see https://github.com/PowerShell/PowerShell/issues/12114#issuecomment-598347725