Quick and Dirty Help

I like writing help text for my scripts.  Yes, PSH V2 allows Get-Help to parse the inline help in scripts, but I'm stuck in V1 for my production environment.  For quick-and-dirty scripts where I don't want to implement a 'real' help subsystem, I use the following:

    if ($help) {
        $functionName = (Get-Variable MyInvocation -Scope 1).Value.MyCommand.Name;
        ((Get-Content function:\$functionName).ToString().Split("`n") | Select-String "^\s+##") -replace '^\s+##\s?' | more;

This searches the function for any line beginning with "##" and strips it out, along with one whitespace character, if present.

Comments (0)

Skip to main content