10.10.12

4 ways of breaking comment-based help in Powershell

A quick note on the different ways I've found of breaking the comment basaed help in Powershell. I've only started playing with it today. It's a great feature, but it does perhaps seem a little fussy. I've not verified all of these - I'll do so when time allows

Leave the '.' off of a label

If I leave out the full-stop on one of the labels:
SYNOPSIS
Lists services on specified server which are set as autostart but are currently stopped
.DESCRIPTION

Uses wmi to get services into 

It breaks the whole of the help:

PS C:\> help sstop
show-stoppedservices [[-MyServer] ]

Have a function with the same name as a script

If my function name is kept in a ps1 file with the same name as the function, then the help subsytem just shows the different items. If I rename the .ps1 file as follows:

move function-show-stoppedservices.ps1 show-stoppedservices.ps1

And I try to get help on the function (using the full function name - the alias would be OK):  

PS C:\> help show-stoppedservices 
Name                     Category   Synopsis 
----                     --------   -------- 
show-stoppedservices     Function   Lists services on specified serv... show-stoppedservices.ps1 Extern...  show-stoppedservices.ps1 ...

Don't name the parameter correctly

If you mis-spell the name of the parameter in the Help text, then you'll lose any description that you add in, obviously enough:

.PARAMETER NotMyServer
Specify the remote server. If null tells you about wherever you are
running

Code:
Param ( [String] $MyServer = "." )

Powershell will still give you the definition of the parameter but you lose the help text.

PS p:\powershell\functions> help show-stoppedservices -parameter MyServer

type                       name                       parameterValue
----                       ----                       --------------
@{name=String}             MyServer                   String

Putting this right:

.PARAMETER MyServer

Allows Powershell to use your help:
PS p:\powershell\functions> help show-stoppedservices -parameter MyServer

type                name                parameterValue      description
----                ----                --------------      -----------
@{name=String}      MyServer            String              {@{Text=Specify ...






Not (re-) sourcing the function! :)

To be completed