Pattern: Use of default value switch parameter as $True
Issue: -
Switch parameters for commands should default to false.
Change the default value of the switch parameter to be false.
Example of incorrect code:
function Test-Script
{
[CmdletBinding()]
Param
(
[String]
$Param1,
[switch]
$Switch=$True
)
...
}
Example of correct code:
function Test-Script
{
[CmdletBinding()]
Param
(
[String]
$Param1,
[switch]
$Switch=$False
)
...
}