PowerShell / PowerShell/PowerShell

Advance Function's Parameter's Get-Help is inconsistent if comment-based help is used (missing Alias, Default Value, Parameter Set, etc.)

Open
#25,477 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

KeepOpen Up-for-Grabs WG-Interactive-HelpSystem WG-Reviewed
Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 2h
Merged PRs (30d)
88

Description

Prerequisites
Steps to reproduce

Enter in the following code

function Test-GreetingA {
    [CmdletBinding()]
    param (
        [Parameter(
            Position = 0,
            Mandatory,
            ValueFromPipeline
        )]
        [Alias(
            'Subject'
        )]
        [string]
        $Person
    )
    
    begin {
        
    }
    
    process {
        Write-Output "Hello $Person"
    }
    
    end {
        
    }
}



<#
.SYNOPSIS
Test a simple greeting

.DESCRIPTION
A simple greeting that requires a person's name

.PARAMETER Person
The person you want to greet

.EXAMPLE
Test-Greeting -Person 'John Smith'
#>
function Test-GreetingB {
    [CmdletBinding()]
    param (
        [Parameter(
            Position = 0,
            Mandatory,
            ValueFromPipeline
        )]
        [Alias(
            'Subject'
        )]
        [string]
        $Person
    )
    
    begin {
        
    }
    
    process {
        Write-Output "Hello $Person"
    }
    
    end {
        
    }
}

Now run the following Get-Help commands

Get-Help Test-GreetingA -Parameter Person
Get-Help Test-GreetingB -Parameter Person
Expected behavior
-Person <string>

    Required?                    true
    Position?                    0
    Default value                None
    Accept pipeline input?       true (ByValue)
    Parameter set name           (All)
    Aliases                      Subject
    Dynamic?                     false
    Accept wildcard characters?  false

-Person <String>
    The person you want to greet

    Required?                    true
    Position?                    0
    Default value                None
    Accept pipeline input?       true (ByValue)
    Parameter set name           (All)
    Aliases                      Subject
    Dynamic?                     false
    Accept wildcard characters?  false
Actual behavior
-Person <string>
    
    Required?                    true
    Position?                    0
    Accept pipeline input?       true (ByValue)
    Parameter set name           (All)
    Aliases                      Subject
    Dynamic?                     false
    Accept wildcard characters?  false


-Person <String>
    The person you want to greet

    Required?                    true
    Position?                    1
    Default value
    Accept pipeline input?       true (ByValue)
    Aliases
    Accept wildcard characters?  false
Error details

Incorrect output includes (disparity between Get-Help's output for Test-GreetingA vs. Test-GreetingB):

  • 'Default value' is missing (A)
  • 'Position' is incremented (B)
  • 'Parameter set name' is missing (B)
  • 'Dynamic' is missing (B)
  • 'Default value' right hand value is not showing (B)
  • 'Aliases' right hand value is not showing (B)
Environment data
Name                           Value
----                           -----
PSVersion                      7.5.1
PSEdition                      Core
GitCommitId                    7.5.1
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visuals

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the discrepancy with the two Test-GreetingA and Test-GreetingB functions, then compare the Get-Help output for their Person parameters. Done means comment-based help preserves the expected Default value, Position, Parameter set name, Aliases, Dynamic, and related fields consistently with syntax-based help.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.