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

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

function Get-Foo
{
        [CmdletBinding()]
        [OutputType([String])]
        Param(
        )
        return 4
}

Correct code

function Get-Foo
{
        [CmdletBinding()]
        [OutputType([String])]
        Param(
        )

        return 'four'
}

Source

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