2012-04-06 50 views
1

我创建了一个小的脚本来测试创建我自己的帮助基于PowerShell和我收到的错误:的PowerShell:基于注释的帮助

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

继承人的测试脚本:

<# 
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

看起来你在.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". 
+0

我把一个。在前面,仍然是相同的问题 – resolver101 2012-04-06 20:23:12

+0

获取帮助被代理?尝试运行到'Get-Command Get-Help | Format-List *'来查看'Get-Help'来自哪个模块。 – 2012-04-06 21:03:09

+0

PowerShell脚本也通过安全管理员不喜欢的UNC路径运行。本地复制并解决问题。 – resolver101 2012-04-07 17:50:24

0

您可以使用免费的任务编辑器中调用PowerGui。对于具有高级帮助的功能,您已经有了一个片段(CTRL + I)。它给你所有的高级帮助关键字,您可以在about_Comment_Based_Help

找到你可以把<# #> befor你的函数或里面,但要小心的帮助这里面特殊字符的原因我一些错误,当复制/粘贴从一些例子净或PDF文件。