description | ms.custom | ms.date | ms.topic | title |
---|---|---|---|---|
Switch Parameters Should Not Default To True |
PSSA v1.21.0 |
10/18/2021 |
reference |
AvoidDefaultValueSwitchParameter |
Severity Level: Warning
Switch parameters for commands should default to false.
Change the default value of the switch parameter to be false.
function Test-Script
{
[CmdletBinding()]
Param
(
[String]
$Param1,
[switch]
$Switch=$True
)
...
}
function Test-Script
{
[CmdletBinding()]
Param
(
[String]
$Param1,
[switch]
$Switch=$False
)
...
}