Is there a way to get Powershell 5 Get-Help to parse the current script?
I have a trivially simple script:
function a-func {
}
<#
.Synopsis
Testing Get-Help
#>
function another-func {
}
Get-Help another-func
I don't have a Powershell 3 or 4 machine to test it, but I seem to remember that this worked until PS 5. In the Powershell 5.0 console, this is the output:
C: \ Users \ Administrator \ Documents \ WindowsPowerShell>. \ Testhelp.ps1 Get-Help: Get-Help could not find another-func in the help file in this session. To download updated Help topics, enter: "Update-Help". To get help online, find the Help topic in the TechNet Library at http://go.microsoft.com/fwlink/?LinkID=107116 . In C: \ Users \ Administrator \ Documents \ WindowsPowerShell \ testhelp.ps1: 13 char: 1 + Get-Help other-func + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: ResourceUnavailable: (:) [Get-Help], HelpNotFoundException + FullyQualifiedErrorId: HelpNotFound, Microsoft.PowerShell.Commands.GetHelpCommand
I tried to post a help comment both directly before the function and inside it.
Is this a regression in Powershell 5, or am I doing it wrong? The goal is to get the help output based on each function from the script.
A little more detail:
> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10105 0
> [System.Environment]::OSVersion
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 6.3.9600.0 Microsoft Windows NT 6.3.9600.0
source to share
Comment-based help for a function can appear in one of three places: - At the beginning of the function body. - At the end of the body function. - Before the function keyword. There cannot be more than one blank line between the last line of function help and the Function keyword.
Try:
function a-func {
}
function another-func {
<#
.Synopsis
Testing Get-Help
#>
}
Paste the code into ISE powershell, highlight functions and press F8, then run the following command in the console panel: PS> Get-Help another-func
Microsoft link to this: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help?view=powershell-5.0
** Sorry if there are formatting issues, answered this from my phone
source to share