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

> Use process block for command that accepts input from pipeline.

`powershell/PSUseProcessBlockForPipelineCommand` 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/PSUseProcessBlockForPipelineCommand"]` or by setting
> `rules.powershell.PSUseProcessBlockForPipelineCommand.severity = "warning"` in `.tally.toml`.

## Description

Functions that support pipeline input should always handle parameter input in a process block.
Unexpected behavior can result if input is handled directly in the body of a function where
parameters declare pipeline support.

## Examples

### Problematic code

```powershell theme={null}
Function Get-Number
{
    [CmdletBinding()]
    Param(
        [Parameter(ValueFromPipeline)]
        [int]
        $Number
    )

    $Number
}
```

#### Result

```text theme={null}
PS C:\> 1..5 | Get-Number
5
```

### Correct code

```powershell theme={null}
Function Get-Number
{
    [CmdletBinding()]
    Param(
        [Parameter(ValueFromPipeline)]
        [int]
        $Number
    )

    process
    {
        $Number
    }
}
```

#### Result

```text theme={null}
PS C:\> 1..5 | Get-Number
1
2
3
4
5
```

## Source

This rule documentation is adapted from Microsoft's PSScriptAnalyzer documentation for
[UseProcessBlockForPipelineCommand](https://github.com/MicrosoftDocs/PowerShell-Docs-Modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseProcessBlockForPipelineCommand.md),
licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).


## Related topics

- [powershell/PSUseShouldProcessForStateChangingFunctions](https://tally.wharflab.com/rules/powershell/PSUseShouldProcessForStateChangingFunctions.md)
- [powershell/PSUseCompatibleCommands](https://tally.wharflab.com/rules/powershell/PSUseCompatibleCommands.md)
- [powershell/PSUseCompatibleTypes](https://tally.wharflab.com/rules/powershell/PSUseCompatibleTypes.md)
- [powershell/PSUseConstrainedLanguageMode](https://tally.wharflab.com/rules/powershell/PSUseConstrainedLanguageMode.md)
- [powershell/PSUseSupportsShouldProcess](https://tally.wharflab.com/rules/powershell/PSUseSupportsShouldProcess.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.