2

A short explanation of the scenario.

I am making an object using the New-Module CmdLet. Something like this:

$object = New-Module -Name 'Logger' {
    New-Variable -Name level -Value 200 -Option Constant
    Function log($msg) { Write-Host "$($script:level): $msg" }
    Export-ModuleMember -Variable * -Function *
} -AsCustomObject

$object.log("New user")

I am using that method to create an object since it is the only method (that I have learned of) that that gives me object constants comment-based help for Functions. However, I want to add comments to the whole ScriptBlock or Module so that when I do Get-Help $object I get the help Text. I tried by putting a commented based help text on the beginning of the Scriptblock:

$object = New-Module -Name 'Logger' {
<#
    Helpful info.
#>
    New-Variable -Name level -Value 200 -Option Constant
    Function log($msg) { Write-Host "$($script:level): $msg" }
    Export-ModuleMember -Variable * -Function *
} -AsCustomObject

It creates the object, but running it through Get-Help just gives me Get-Help's help text.

Is there a better way to do this or something I am missing. Or there is no such capabilities?

Tony L.
  • 7,988
  • 5
  • 24
  • 28

1 Answers1

2

There is no top-level help for modules short of creating an about_{your-module-name}.txt file. Try getting help on say PSWorkflow or PSScheduledJob or any other module. The only thing that will do is list the commands unless there is an about_ topic for the module. You get the about_pscx.txt topic when you execute "Get-Help Pscx" for that module. And that mechanism works by placing the about_ topic file next to the associated module files. Not sure how that would work for a dynamic module like you are creating.

Keith Hill
  • 194,368
  • 42
  • 353
  • 369
  • I did more research about the about_topic help file. It seems I can do it with a dynamic module. Too bad there is no way to make a dynamic manifest for the module. – Tony L. Nov 08 '13 at 14:05