description | ms.date | ms.topic | title |
---|---|---|---|
Avoid Using Username and Password Parameters |
06/28/2023 |
reference |
AvoidUsingUsernameAndPasswordParams |
Severity Level: Error
To standardize command parameters, credentials should be accepted as objects of type PSCredential. Functions should not make use of username or password parameters.
Change the parameter to type PSCredential.
function Test-Script
{
[CmdletBinding()]
Param
(
[String]
$Username,
[SecureString]
$Password
)
...
}
function Test-Script
{
[CmdletBinding()]
Param
(
[PSCredential]
$Credential
)
...
}