Functions/Authentication/PSCredential/New-CredentialContainer.ps1

<#
.DESCRIPTION
    This is a factory function to create a custom object containing a PSCredential along with specific metadata about it.
    It is used by both the ESS And MCM Cache types to normalize credential retrieval
 
#>

Function New-CredentialContainer
{
    [CmdletBinding()]
    Param
    (
        # Name
        [Parameter(Mandatory=$True)]
        [String]
        $Name,

        # Description
        [Parameter(Mandatory=$True)]
        [String]
        $Description,

        # Date Created
        [Parameter(Mandatory=$True)]
        [datetime]
        $Date,

        # Username
        [Parameter(Mandatory=$True)]
        [String]
        $Username,

        # Credential
        [Parameter(Mandatory=$True)]
        [PSCredential]
        $Credential
    )

    Process
    {
        # Create Object from Input Parameters
        [pscustomobject]([ordered]@{
            Name = $Name
            Description = $Description
            Date = $Date
            Username = $Username
            Credential = $Credential
        })
    }
}