2

When I add a help section to my script, the Get-Help cmdlet displays a different syntax. Here is a MWE:

#Require -Version 4.0
function global:Test-Syntax {
    <#
    .Synopsis
        Cmdlet tests ValidateSet
    #>
    [CmdletBinding()]
    # parameter check
    param (
        [ValidateSet("one", "two", "three")]
        [string]$testparam
    )
    Write-Verbose "`$testparam: $testparam"
}

Get-Help Test-Syntax shows the following in syntax section:

SYNTAX
    Test-Syntax [[-testparam] <String>] [<CommonParameters>]

After I remove .Synopsis or the whole help section, I receive the following from Get-Help:

SYNTAX
    Test-Syntax [[-testparam] <string> {one | two | three}]  [<CommonParameters>]

I would like to have the second one, because a user directly get the information about the validated set. How can I get this help with a defined .Synopsis?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Dirk
  • 1,134
  • 2
  • 12
  • 21

1 Answers1

0

This looks like a bug in how the syntax is automatically generated when you have comment help.

As a workaround, you could write a maml file and use the .ExternalHelp comment. This is an unfortunate workaround though, because maml is not easy to write, I would recommend using a tool, there is at least one commercial product or free ones on github/codeplex.

I would suggest opening an item here: https://windowsserver.uservoice.com/forums/301869-powershell

Jason Shirk
  • 7,734
  • 2
  • 24
  • 29
  • I opened a thread here: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11290704-syntax-changes-when-using-help-like-synopsis – Dirk Jan 03 '16 at 10:32