问题描述
我正在尝试使用 Get-Help cmdlet 以与显示从 XML 文件生成的 cmdlet 帮助主题相同的格式显示基于注释的帮助.TechNet 上的 about_Comment_based_Help 中记录了执行此操作的能力,但是当我对我的脚本执行 get-help cmdlet 我只得到返回的脚本名称.任何帮助将不胜感激!
PS C:\Admin>获取帮助 .\checksystem.ps1 -full检查系统.ps1
checksystem.ps1 脚本:
function IsAlive {<#.描述检查计算机是否可以 ping 通..PARAMETER 计算机名指定计算机名..例子IsAlive -computername testwks01.笔记这只是一个示例函数.#>参数 ($计算机名)测试连接 -count 1 -ComputerName $computername -TimeToLive 5 |Where-Object { $_.StatusCode -eq 0 } |选择对象 -ExpandProperty 地址}IsAlive -计算机名 192.168.1.1
它会起作用,但您正在尝试运行获取有关脚本的帮助.您已为该功能添加了帮助.如果您点源脚本,然后键入 get-help isalive,您将看到该函数的帮助.
..\checksystem.ps1 ;get-help isalive -fullI am trying to use the Get-Help cmdlet to display comment-based help in the same format in which it displays the cmdlet help topics that are generated from XML files. The ability to do this is documented in about_Comment_based_Help on TechNet, but when I execute the get-help cmdlet against my script I only get the script name returned. Any help would be appreciated!
PS C:\Admin> Get-Help .\checksystem.ps1 -full
checksystem.ps1
checksystem.ps1 script:
function IsAlive {
<#
.DESCRIPTION
Checks to see whether a computer is pingable or not.
.PARAMETER computername
Specifies the computername.
.EXAMPLE
IsAlive -computername testwks01
.NOTES
This is just an example function.
#>
param (
$computername
)
Test-Connection -count 1 -ComputerName $computername -TimeToLive 5 |
Where-Object { $_.StatusCode -eq 0 } |
Select-Object -ExpandProperty Address
}
IsAlive -computername 192.168.1.1
It will work, but you are trying to run get help on the script. You have added the help to the function. If you dot source your script, and then type get-help isalive, you will see your help for the function.
. .\checksystem.ps1 ; get-help isalive -full
这篇关于使用 Get-Help cmdlet 以相同格式显示基于注释的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!