Skip to content

Latest commit

 

History

History
53 lines (43 loc) · 828 Bytes

AvoidUsingUsernameAndPasswordParams.md

File metadata and controls

53 lines (43 loc) · 828 Bytes
description ms.custom ms.date ms.topic title
Avoid Using Username and Password Parameters
PSSA v1.22.0
06/28/2023
reference
AvoidUsingUsernameAndPasswordParams

AvoidUsingUsernameAndPasswordParams

Severity Level: Error

Description

To standardize command parameters, credentials should be accepted as objects of type PSCredential. Functions should not make use of username or password parameters.

How

Change the parameter to type PSCredential.

Example

Wrong

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

Correct

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