Skip to main content

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/PSReviewUnusedParameter is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.
PropertyValue
SeverityWarning
CategoryPSScriptAnalyzer
Auto-fixNo

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.
@{
    Rules = @{
        PSReviewUnusedParameter = @{
            CommandsToTraverse = @(
                'Invoke-PSFProtectedCommand'
            )
        }
    }
}

How

Consider removing the unused parameter.

Examples

Problematic code

function Test-Parameter
{
    Param (
        $Parameter1,

        # this parameter is never called in the function
        $Parameter2
    )

    Get-Something $Parameter1
}

Correct code

function Test-Parameter
{
    Param (
        $Parameter1,

        # now this parameter is being called in the same scope
        $Parameter2
    )

    Get-Something $Parameter1 $Parameter2
}

Source

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