UseOutputTypeCorrectly
Severity Level: Information
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.
Example
Wrong
function Get-Foo
{
[CmdletBinding()]
[OutputType([String])]
Param(
)
return 4
}
Correct
function Get-Foo
{
[CmdletBinding()]
[OutputType([String])]
Param(
)
return 'four'
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for