> ## 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

> ReviewUnusedParameter

`powershell/PSReviewUnusedParameter` is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.

| Property | Value             |
| -------- | ----------------- |
| Severity | Warning           |
| Category | PSScriptAnalyzer  |
| Default  | Disabled in tally |
| Auto-fix | No                |

<Note>
  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`.
</Note>

## 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.

```powershell theme={null}
@{
    Rules = @{
        PSReviewUnusedParameter = @{
            CommandsToTraverse = @(
                'Invoke-PSFProtectedCommand'
            )
        }
    }
}
```

## How

Consider removing the unused parameter.

## Examples

### Problematic code

```powershell theme={null}
function Test-Parameter
{
    Param (
        $Parameter1,

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

    Get-Something $Parameter1
}
```

### Correct code

```powershell theme={null}
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](https://github.com/MicrosoftDocs/PowerShell-Docs-Modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/ReviewUnusedParameter.md),
licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
