1

I've created a small script to test creating my own help based powershell and i received error:

Get-Help : Cannot find Help for topic ".\testHelp.ps1". At line:49 char:15 + Get-Help <<<< @PSBoundParameters | more + CategoryInfo : ResourceUnavailable: (:) [Get-Help], HelpNotFoundException + FullyQualifiedErrorId : HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand

Heres the test script:

<#
SYNOPSIS
retrieive a list of services from local and remote machines 
.DESCRIPTION
Retrieive services from local and remote machines and reports the following fields
.PARAMETER  Servers 
The Get-Service cmdlet gets objects that represent the services on a local computer or on a remote computer.
.EXAMPLE
PS C:\> Get-Something 'One value' 32
#>
param($computername="localhost")
Get-WmiObject -Class Win32_BIOS -ComputerName $computername
4

2 回答 2

4

看起来你错过了.前面的.SYNOPSIS. 您的帮助还说参数被调用Servers但参数块说$computername。尽管我认为它不能验证参数名称,但 PowerShell 对帮助格式的正确性非常挑剔。:-)

结果是:

PS> Get-Content .\FuncHelp.ps1
<#
.SYNOPSIS
retrieive a list of services from local and remote machines 
.DESCRIPTION
Retrieive services from local and remote machines and reports the following fields
.PARAMETER  Servers 
The Get-Service cmdlet gets objects that represent the services on a local computer or on a remote computer.
.EXAMPLE
PS C:\> Get-Something 'One value' 32
#>
param($computername="localhost")
Get-WmiObject -Class Win32_BIOS -ComputerName $computername


PS> .\FuncHelp.ps1 -?

NAME
    C:\Users\hillr\FuncHelp.ps1

SYNOPSIS
    retrieive a list of services from local and remote machines


SYNTAX
    C:\Users\hillr\FuncHelp.ps1 [[-computername] <Object>] [<CommonParameters>]


DESCRIPTION
    Retrieive services from local and remote machines and reports the following fields


RELATED LINKS

REMARKS
    To see the examples, type: "get-help C:\Users\hillr\FuncHelp.ps1 -examples".
    For more information, type: "get-help C:\Users\hillr\FuncHelp.ps1 -detailed".
    For technical information, type: "get-help C:\Users\hillr\FuncHelp.ps1 -full".
于 2012-04-06T15:16:25.567 回答
0

您可以使用名为PowerGui的免费 Quest 编辑器。您已经获得了具有高级帮助的功能片段 (CTRL+I)。它为您提供了您可以在about_Comment_Based_Help中找到的所有高级帮助关键字

您可以在<# #>您的函数之前或内部输入,但请注意帮助中的特殊字符,当从网络或 PDF 文档中复制/粘贴一些示例时,它会导致我出现一些错误。

于 2012-04-07T07:08:58.773 回答