Including .ALIASES within my help without breaking it.


This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Steven Ayers Steven Ayers 10 months, 2 weeks ago.

  • Author
  • #33028
    Profile photo of Steven Ayers
    Steven Ayers

    I want to include the alias header, as the built in functions do, however, when I do, it breaks my examples, which don't show up when I do Get-Help Get-Foo -Full with .ALIASES added to the help snippet.

    Do you know if there is a workaround for this?


  • #33032
    Profile photo of Matt Bloomfield
    Matt Bloomfield

    .ALIASES isn't listed in the help file Get-Help about_comment_based_help as a valid keyword.

    From testing, this looks like a bug. It appears that any invalid keyword in the help inserts an ALIASES section and remove the examples:

    In the ISE add the Cmdlet (advanced function) snippet.
    Add .TESTKEYWORD to the help section.
    Add Get-Help Verb-Noun -Full to the end of the script.
    Run the script.

  • #33040
    Profile photo of Daniel Krebs
    Daniel Krebs

    The ALIASES section of the get-help output is being auto-generated by the help system.

    function Start-Test
    {  }

    Just execute:

    Set-Alias stt Start-Test
    Get-Help Start-Test -Full # Should show the alias now

    In a module file (.psm1) you would define the aliases as shown below:

    function Start-Test
    {  }
    Set-Alias stt Start-Test
    Export-ModuleMember -Function Start-Test -Alias stt

    I hope that helps.

  • #33075
    Profile photo of Steven Ayers
    Steven Ayers

    Daniel, That's strange because mine doesn't generate an ALIASES on my functions. Here's my code:

    function Connect-MsolTenant
    New-Alias connect Connect-MsolTenant

    This is stored in a PowerShell Profile, not a module. Is the reason because I am using New-Alias perhaps?

You must be logged in to reply to this topic.