Placing Comment-Based Help in Functions
This topic explains where to place comment-based help for a function so that the Get-Help
cmdlet
associates the comment-based help topic with the correct function.
At the beginning of the function body.
At the end of the function body.
Before the
Function
keyword. When the function is in a script or script module, there can't be more than one blank line between the last line of the comment-based help and theFunction
keyword. Otherwise,Get-Help
associates the help with the script, not with the function.
The following examples show each of the three placement options for comment-based help for a function.
The following example shows comment-based at the beginning of a function body.
function MyProcess
{
<#
.Description
The MyProcess function gets the Windows PowerShell process.
#>
Get-Process powershell
}
The following example shows comment-based at the end of a function body.
function MyFunction
{
Get-Process powershell
<#
.Description
The MyProcess function gets the Windows PowerShell process.
#>
}
The following examples shows comment-based on the line before the function keyword.
<#
.Description
The MyProcess function gets the Windows PowerShell process.
#>
function MyFunction { Get-Process powershell}
PowerShell feedback
PowerShell is an open source project. Select a link to provide feedback: