| description | Switch Parameters Should Not Default To True |
|---|---|
| ms.custom | PSSA v1.21.0 |
| ms.date | 06/28/2023 |
| ms.topic | reference |
| title | 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
)
...
}