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

> Use OutputType Correctly

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

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

## Description

A command should return the same type as declared in `OutputType`.

You can get more details by running `Get-Help about_Functions_OutputTypeAttribute` command in
PowerShell.

## How

Specify that the OutputType attribute lists and the types returned in the cmdlet match.

## Examples

### Problematic code

```powershell theme={null}
function Get-Foo
{
        [CmdletBinding()]
        [OutputType([String])]
        Param(
        )
        return 4
}
```

### Correct code

```powershell theme={null}
function Get-Foo
{
        [CmdletBinding()]
        [OutputType([String])]
        Param(
        )

        return 'four'
}
```

## Source

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


## Related topics

- [powershell/PSUseCmdletCorrectly](https://tally.wharflab.com/rules/powershell/PSUseCmdletCorrectly.md)
- [powershell/PSUseCompatibleTypes](https://tally.wharflab.com/rules/powershell/PSUseCompatibleTypes.md)
- [powershell/PSUsePSCredentialType](https://tally.wharflab.com/rules/powershell/PSUsePSCredentialType.md)
- [powershell/PSUseConstrainedLanguageMode](https://tally.wharflab.com/rules/powershell/PSUseConstrainedLanguageMode.md)
- [powershell/PSUseCorrectCasing](https://tally.wharflab.com/rules/powershell/PSUseCorrectCasing.md)


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