Comment-based help in PowerShell is a comment block with keywords such as .SYNOPSIS inside your function or script. Get-Help reads it like built-in cmdlet help:
function Get-StoreSales {
<#
.SYNOPSIS
Gets the sales total for a store.
#>
param([string]$City)
"${City}: 12500 USD"
}
(Get-Help Get-StoreSales).Synopsis
Output:
Gets the sales total for a store.
In this tutorial, I’ll show you how to write comment-based help in PowerShell for functions and scripts, where the block has to go, and what Get-Help shows differently in PowerShell 7 and 5.1.
The sample function we’ll document
Every example uses the same small function, Get-StoreSales. Without any help block, Get-Help can only describe its syntax:
function Get-StoreSales {
param([string]$City, [int]$Month = 1)
"$City store, month ${Month}: 12500 USD"
}
Get-StoreSales -City Austin
Get-Help Get-StoreSales
Output:
Austin store, month 1: 12500 USD
NAME
Get-StoreSales
SYNTAX
Get-StoreSales [[-City] <string>] [[-Month] <int>]
ALIASES
None
REMARKS
None
NAME and SYNTAX come from the code itself. If you’re new to writing them, start with functions in PowerShell. Plain notes for other people reading the code are a different thing, covered in adding comments in PowerShell.
Method 1: Add a help block inside the function
Put a <# #> block at the top of the function body. Each section starts with a keyword on its own line, and the text goes on the lines below it:
function Get-StoreSales {
<#
.SYNOPSIS
Gets the sales total for a store.
.DESCRIPTION
Get-StoreSales returns the sales total in USD for one store.
Use -Month to pick a month in 2026.
.PARAMETER City
The store city, such as Austin or Denver.
.PARAMETER Month
The month number (1-12). The default is 1.
.EXAMPLE
Get-StoreSales -City Austin
Returns the January 2026 total for the Austin store.
.EXAMPLE
Get-StoreSales -City Denver -Month 3
.LINK
PowerShell Function Parameters: Create Functions with param Blocks
#>
param(
[Parameter(Mandatory)]
[string]$City,
[int]$Month = 1
)
"$City store, month ${Month}: 12500 USD"
}
Get-Help Get-StoreSales
Output:
NAME
Get-StoreSales
SYNOPSIS
Gets the sales total for a store.
SYNTAX
Get-StoreSales [-City] <String> [[-Month] <Int32>] [<CommonParameters>]
DESCRIPTION
Get-StoreSales returns the sales total in USD for one store.
Use -Month to pick a month in 2026.
RELATED LINKS
PowerShell Function Parameters: Create Functions with param Blocks
REMARKS
To see the examples, type: "Get-Help Get-StoreSales -Examples"
For more information, type: "Get-Help Get-StoreSales -Detailed"
For technical information, type: "Get-Help Get-StoreSales -Full"
For online help, type: "Get-Help Get-StoreSales -Online"
