AL/New-CredentialFromEnvironmetJson.ps1

function New-CredentialFromEnvironmentJson {
    param (
        # Source path containing environment.json
        [Parameter(Mandatory=$false)]
        [string]
        $SourcePath = (Get-Location)
    )

    if ($null -eq (Get-EnvironmentKeyValue -SourcePath $SourcePath -KeyName 'password')) {
        return $false
    }

    $Password = ConvertTo-SecureString (Get-EnvironmentKeyValue -SourcePath $SourcePath -KeyName 'password') -AsPlainText -Force
    return New-Object System.Management.Automation.PSCredential((Get-EnvironmentKeyValue -SourcePath $SourcePath -KeyName 'user'), $Password)
}

Export-ModuleMember -Function New-CredentialFromEnvironmentJson