Functions/Authentication/PSCredential/New-Credential.ps1

# This is not particularly secure, since you're building your credentials from plaintext and that will stick in the session memory.
Function New-Credential
    {
    [Cmdletbinding()]
    Param
        (
        # Username for Cred
        [Parameter(Mandatory=$true)]
        [string]
        $Username,

        # Password for Cred
        [Parameter(Mandatory=$true)]
        [string]
        $Password 
        )
    Process
        {
        # Create SecureString Password
        [securestring]$SSPW =  ConvertTo-SecureString $Password  -AsPlainText -Force

        # Create Credential Object
        New-Object System.Management.Automation.PSCredential($userName, $SSPW)
        }
    }