Skip to main content
powershell/PSReviewUnusedParameter 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/PSReviewUnusedParameter"] or by setting rules.powershell.PSReviewUnusedParameter.severity = "warning" in .tally.toml.

Description

This rule identifies parameters declared in a script, scriptblock, or function scope that have not been used in that scope.

Configuration settings

By default, this rule doesn’t consider child scopes other than scriptblocks provided to Where-Object or ForEach-Object. The CommandsToTraverse setting is a string array that allows you to add additional commands that accept scriptblocks that this rule should examine.

How

Consider removing the unused parameter.

Examples

Problematic code

Correct code

Source

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