I am trying to implement Comment Based Help as described here with Powershell 5.1 on Windows Server 2016.
The script I am using is called blah.ps1:
<#
.DESCRIPTION
blah blah
#>
function Blahblah
{
}
In Powershell, I can load the script:
.\blah.ps1
But when I ask for help on this function using:
Get-Help Blahblah
Powershell only reports an error:
Get-Help : Get-Help could not find Blahblah in a help file in this session. To download updated help topics type: "Update-Help". To get help online, search for the help topic in the TechNet library at http://go.microsoft.com/fwlink/?LinkID=107116.
At line:1 char:1
+ Get-Help Blahblah
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Get-Help], HelpNotFoundException
+ FullyQualifiedErrorId : HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand
I am assuming that Get-Help can be used with the custom help comments. What am I missing?
Import the script as a module instead of running it.
Import-Module .\blah.ps1
While declaring the function, including the help immediately after the function header, saving it in a module, and importing the module is probably the best way to handle it, you can make your script's help available to Get-Help by ensuring that...
$env:PATH.The help for the function can be declared before the function itself is, provided that there is no more than one blank line between the help's closing #> and the beginning of the function declaration.
See Get-Help about_Comment_Based_Help in either the PowerShell help or the linked Microsoft documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With