Private/Get-PDKPlainPassword.ps1

function Get-PDKPlainPassword() {
    <#
    .SYNOPSIS
        Convert SecureString password to plain text
    .NOTES
        File Name : Get-PDKPlainPassword.ps1
        Author : Thomas ILLIET (contact@thomas-illiet.fr)
    #>

    [CmdletBinding()]
    [OutputType([String])]
    param (
        [parameter(Mandatory = $true)]
        [System.Security.SecureString]$SecureString
    )

    $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString);
    try {
        return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr);
    } finally {
        [Runtime.InteropServices.Marshal]::FreeBSTR($bstr);
    }

}