Module/Misc/Get-BCSCredential.ps1

<#
.SYNOPSIS
    Get a System.Management.Automation.PSCredential object
.DESCRIPTION
    Creates a System.Management.Automation.PSCredential object based on UserName and Password
     
.PARAMETER userName
  Username
.PARAMETER securePassword
  SecureString caontaining the password
 
.NOTES
    Author: Mathias Stjernfelt
    Website: http://www.brightcom.se
 
.EXAMPLE
    $cred = Get-BCSCredential myUserName (Get-BCSSecureString P@ssword)
#>

function Get-BCSCredential {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
    Param(
        [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)]
        [String] $userName,
        [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)]
        [SecureString] $securePassword
    )

    New-Object System.Management.Automation.PSCredential -argumentList $userName, $securePassword
}
Export-ModuleMember -Function Get-BCSCredential