r/PowerShell • • Jul 28 '26

Question Looking for an authoritative PowerShell comment-based help (.SYNOPSIS, .DESCRIPTION, etc.) style guide / best practices

Hi everyone. I’m trying to define a consistent standard for our team’s PowerShell scripts, specifically around comment-based help sections like .SYNOPSIS, .DESCRIPTION, .PARAMETER, .EXAMPLE, .NOTES and so on. We mostly write admin automation scripts, Graph, Entra ID and infra tasks. So I’d like every script to follow the same high-quality documentation pattern. I’m not looking for basic definitions, but for authoritative guidance from sources like Microsoft Learn, PowerShell.org, or well-respected community style guides. Things like how long a synopsis ideally is, what belongs in description versus notes, whether there are any recommended conventions that Microsoft has published. Ultimately, I want to create a company template that isn’t just my opinion, but grounded in recognised best practice. Does anyone have solid references or recommendations? Thanks in advance.

33 Upvotes

12 comments sorted by

View all comments

Show parent comment

5

u/surfingoldelephant Jul 28 '26

They suggest inlining parameter descriptions. I prefer having .PARAMETER statements within the block comment, so it can be read in its entirety before the code is reached. Either way, it doesn't make a difference to Get-Help output.

They also suggest indenting like this:

<#
    .Keyword
        Blah ...
#>

Whereas I prefer:

<#
.Keyword
    Blah ...
#>

Entirely personal preference. And again, it doesn't make a difference to Get-Help output, since leading white space is stripped before the PS formatter adds a 4 space indent afterwards.

2

u/MonkeyNin Jul 29 '26

+1 . comments before parameters still builds the help file:

function DoSomething { 

    param(
        # Any -FormatView commands.
        [Parameter(ValueFromPipelineByPropertyName)]
        [ScriptBlock[]]
        $Format,
    
        # Any -TypeView commands.
        [Parameter(ValueFromPipelineByPropertyName)]
        [ScriptBlock[]]
        $Type,
    )

    # ...
}

You can verify it like this:

gcm 'Write-EZFormatFile' | Get-Help -Detailed

Example is from: https://github.com/StartAutomating/EZOut/blob/82ea997b0e2b502964400a5a964931c9da25fbb6/Commands/Write-EZFormatFile.ps1#L9-L18