Add Help to Your Functions

by Jul 6, 2010

You should simply copy and paste the following block comment right above your functions and magically Get-Help works with your functions, too!

A brief description of the function.
A detailed description of the function.
.PARAMETER something
The description of the first parameter.
PS C:> My-Test -something 'string value'
Additional information about the function goes here.
Function My-Test($something) { 'Call Get-Help My-Test to see my help!' }

So to get Help, after running the code, you should try this:

Get-Help My-Test
Get-Help My-Test -examples

You won't get help with PowerShell v1, and you won't get Help if the Help block is wrongly located. It can be right above a function (no more than one blank line), or first/last thing inside the function.