Documentation Index
Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
Use this file to discover all available pages before exploring further.
powershell/PSAvoidDefaultValueSwitchParameter is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.
| Property | Value |
|---|---|
| Severity | Warning |
| Category | PSScriptAnalyzer |
| Auto-fix | No |
Description
If your parameter takes onlytrue and false, define the parameter as type [Switch]. PowerShell
treats a switch parameter as true when it’s used with a command. If the parameter isn’t included
with the command, PowerShell considers the parameter to be false. Don’t define [Boolean]
parameters.
You shouldn’t define a switch parameter with a default value of $true because this isn’t the
expected behavior of a switch parameter.
How
Change the default value of the switch parameter to be$false or don’t provide a default value.
Write the logic of the script to assume that the switch parameter default value is $false or not
provided.