Skip to main content
powershell/PSAvoidDefaultValueForMandatoryParameter is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.
tally disables this rule by default for Dockerfile RUN snippets because a RUN executes statements inline rather than defining cmdlets, parameters, or modules with external callers. Re-enable it with include = ["powershell/PSAvoidDefaultValueForMandatoryParameter"] or by setting rules.powershell.PSAvoidDefaultValueForMandatoryParameter.severity = "warning" in .tally.toml.

Description

Mandatory parameters should not have a default value because there is no scenario where the default can be used. PowerShell prompts for a value if the parameter value is not specified when calling the function.

Examples

Problematic code

Correct code

Source

This rule documentation is adapted from Microsoft’s PSScriptAnalyzer documentation for AvoidDefaultValueForMandatoryParameter, licensed under CC BY 4.0.