ConvertFrom-SecureString : A parameter cannot be found that matches parameter name 'AsPlainText'
Niels Swimberghe - - PowerShell
Follow me on Twitter, buy me a coffee
PowerShell 7 introduces a new option AsPlainText
to the ConvertFrom-SecureString
function. When using this new flag, you receive the plain text version of the secure string. If you're using older versions of PowerShell, you do not have this flag available and the following error is printed:
"ConvertFrom-SecureString : A parameter cannot be found that matches parameter name 'AsPlainText'."
You're not out of luck though, you can quickly create your own function which will give you the same result:
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; }
Load this function into memory and simply pass in your secure string to get a plain text version string back.