-1

So I've written a few functions to streamline my common tasks, and have tried documenting them with relatively proper Get-Help info. However it does not display.

I have the funtions in my $profile, is that the problem?

Here's one of my functions, I've tried matching about_Comment_Based_Help:

Function Service-Restarter ($service, $vm){

<#
.SYNOPSIS
Restart [redacted] services running on client/server.

.DESCRIPTION
Using the windows "Services" tool to connect to other clients/servers is very slow.
This function quickly restarts the [redacted] services running on a client/server.

.EXAMPLE
Service-Restarter service* Computer-Name-Here

.ALIAS
srestart
#>
    Restart-Service -InputObject $(Get-Service -ComputerName $vm -Name $service)
}
Set-Alias srestart Service-Restarter

This is what Get-Helpreturns:

[41]PS:>help srestart -full

NAME
    Service-Restarter
     SYNTAX
    Service-Restarter [[-service] <Object>] [[-vm] <Object>]

     PARAMETERS
    -service <Object>

        Required?                    false
        Position?                    0
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false

    -vm <Object>

        Required?                    false
        Position?                    1
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false

     INPUTS
    None

     OUTPUTS
    System.Object
     ALIASES
    srestart

REMARKS
    None

And here is what a general search displays:

[45]PS:>help restart

Name              Category Module                    Synopsis
----              -------- ------                    --------
Service-Restarter Function                           ...
Restart-Computer  Cmdlet   Microsoft.PowerShell.M... Restarts ("reboots") the operating system on local and remote computers.
Restart-Service   Cmdlet   Microsoft.PowerShell.M... Stops and then starts one or more services.
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Hargaut
  • 43
  • 5
  • You're leaving a blank line between the `function` line and the beginning of the comment block. Try removing that; I use comment-based help all the time with no problem - but there's no blank line after the opening `{`. – Jeff Zeitlin Feb 01 '19 at 12:33
  • Thanks, I saw some comments regarding a blank line and while writing this I tried removing it. There is currently no blank line in my function, but result is the same. It's very strange indeed. – Hargaut Feb 04 '19 at 10:03
  • I'm voting to close this as the OP has evidently solved the issue by removing what may have been a typo--see OP's edit to OP's comment against RetiredGeek's answer. – Reg Edit Feb 05 '22 at 13:29

2 Answers2

0

Comment based help requires 2 blank lines following the closing #>

RetiredGeek
  • 2,980
  • 1
  • 7
  • 21
  • This did not help, I'm afraid. When I tried writing a short function on my friends PC while on holiday to test this answer, that comment based help worked. So decided to test again on my functions at work, and still same result. Edit: I found it! By removing the .ALIAS it works as intended. Doesn't matter if I've actually set up an alias or not either. – Hargaut Jul 15 '20 at 12:29
0

.ALIAS is not a valid comment-based help keyword. Powershell will display the entry, but omitting everything but name, syntax, aliases, and remarks.

Hargaut
  • 43
  • 5