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?