Edit

AvoidUsingUsernameAndPasswordParams

Severity Level: Error

Description

This rule detects functions that use separate username and password parameters instead of a single PSCredential object. Functions shouldn't use separate username or password parameters. To standardize command parameters, credentials should be accepted as objects of type PSCredential.

Example

Noncompliant

function Test-Script
{
    [CmdletBinding()]
    Param
    (
        [String]
        $Username,
        [SecureString]
        $Password
    )
    ...
}

Compliant

function Test-Script
{
    [CmdletBinding()]
    Param
    (
        [PSCredential]
        $Credential
    )
    ...
}