相比之下,给定模块的 cmdlet 的帮助主题通常作为单个MAML文件(名称包含模块名称的*-help.xml文件)的一部分提供;只有一个版本的此类主题被视为最新版本,因此其内容直接显示(没有列出多个版本). 鉴于此,具有多个概念性帮助主题的不同且晦涩的行为很可能是 bug ,尤其是鉴于您无法分辨出哪个版本列出的项目与;在相关说明中,对于非概念性主题,目前无法查看其他版本的帮助,这似乎是设计限制. 帮助主题可以作为给定模块的一部分提供,或者对于内置模块,可以在与PowerShell可执行文件相同的文件夹中的以该语言命名的子文件夹(例如,en-US)中提供. 至少在PowerShell Core中,按需安装的模块似乎还可以将主题放在$env:PSModulePath中列出的其他文件夹的 sibling 文件夹的Help文件夹中;在这些Help文件夹中, conceptual 帮助主题似乎可以出现在顶层(在特定于语言的文件夹中)和在为模块命名的子文件夹中(在特定于语言的文件夹中)-我不清楚其背后的逻辑. 我不清楚给定帮助主题的多个版本中的确切优先顺序规则/列出顺序;在Windows PowerShell中,似乎首先安装了与powershell.exe一起安装的概念性帮助主题版本,但在PowerShell Core中似乎并非如此. 不幸的是,检查列表项的属性不会显示其源文件,而只会显示其源文件的 length (以字节为单位).但是,您可以独立定位帮助文件:以下 helper函数(功能更全的版本可以从此Gist )以您自己的命令为基础,用于查找给定概念性帮助主题或模块名称的所有帮助文件:function Get-HelpFile($fileNamePart) { # Note the use of Split-Path -Parent, because help files can be in sibling # folders of $env:PSModulePath folders. Split-Path -Parent ($env:PSModulePath -split [IO.Path]::PathSeparator) | Get-ChildItem -File -Recurse -Filter *$fileNamePart* | Where-Object Name -match '(?:\.help\.txt|-help.xml)$'}# Find help source files whose name contains 'about_psreadline'Get-HelpFile about_psreadline您可以传递帮助文件名中包含的任何子字符串,例如模块名,例如PSReadLine,但是请注意,鉴于概念性帮助主题不一定包含与之关联的模块的名称,因此不一定显示与该模块关联的所有帮助文件.另外,某些模块名称未反映在其帮助文件名称中,尤其是模块Microsoft.PowerShell.Core(帮助文件名为System.Management.Automation.dll-Help.xml)和Microsoft.PowerShell.Management(帮助文件名为Microsoft.PowerShell.Commands.Management.dll-Help.xml).如果将上述命令传递给| Select FullName, Length,它将在完整路径旁边列出以字节为单位的文件大小(属性.Length),该文件大小可以与例如Get-Help about_PSReadLine | Select Length所报告的大小相关联,因此以推断主题的列出顺序.Problem: I have two about_psreadline help topics: about_psreadline and about_PSReadLine. Get-Help cmdlet cannot display information on any of them. Get-Help about_psreadline just displays a table with two mentioned help files.Question: How to deal with duplicated HelpFiles? Could/Should one of them be removed?Powershell version: 6.1.3; I also checked PSModulePath and the only path containing PSReadline is C:\program files\powershell\6\Modules 解决方案 Whenever Get-Help shows a list of topics rather than the requested topic's content - despite having provided a specific topic's name - you can call .ToString() on the individual list items to show their content; e.g., to show the 1st item's content:(Get-Help about_PSReadLine)[0].ToString()To show them all, one directly after the other:Get-Help about_PSReadLine | ForEach-Object ToStringAs you've discovered, renaming or removing duplicate files solves the problem persistently; see below for how to find them. However, doing so shouldn't be necessary, as the behavior observed is likely a bug - see this GitHub issue; details below.The problem stems from multiple versions of a given conceptual help topic being available, due to:multiple versions of the underlying PowerShell module being installed...and/or - in the case of in-box modules (modules that ship with PowerShell) - preinstalled help files continuing to be available even after newer versions of in-box modules have been installed.As of Windows PowerShell v5.1 / PowerShell Core 6.2.0, this is only an option for a subset of the in-box modules (PSReadLine, Microsoft.PowerShell.Archive, PackageManagement, PowerShellGet).Note:The multiple-version problem seems to affect only conceptual help topics (about_*), which are implemented as individual *.help.txt files.By contrast, the help topics for a given module's cmdlets are typically delivered as part of a single MAML file (a *-help.xml file whose name contains the module name); only ever one version of such topics is considered current and therefore its content is directly displayed (no listing of multiple versions). In light of that, the differing - and obscure - behavior with multiple conceptual help topics is likely a bug, especially given that you cannot tell what versions the listed items are associated with; on a related note, for non-conceptual topics, there is currently no way to view the other versions' help, which appears to be a design limitation.Help topics can be delivered as part of a given module or, in the case of in-box modules, in subfolders named for the language (e.g., en-US) in the same folder as the PowerShell executable.At least in PowerShell Core, on-demand installed modules seemingly can also place topics in Help folders that are sibling folders of other folders listed in $env:PSModulePath; in these Help folders, conceptual help topics can seemingly be present both at the top-level (in language-specific folders) and in subfolders named for modules (in language-specific folders) - I'm unclear on the logic behind this.I'm unclear on the exact precedence rules / listing order among the multiple versions of a given help topic; in Windows PowerShell, a conceptual help topic version installed alongside powershell.exe seems to come first, but that doesn't appear to be true in PowerShell Core.Unfortunately, inspecting the list items' properties does not reveal their source file, only their source file's length (size in bytes).However, you can locate help files independently: The following helper function (a more fully-featured version of which can be downloaded from this Gist) builds on your own command for locating all help files for a given conceptual help topic or module name:function Get-HelpFile($fileNamePart) { # Note the use of Split-Path -Parent, because help files can be in sibling # folders of $env:PSModulePath folders. Split-Path -Parent ($env:PSModulePath -split [IO.Path]::PathSeparator) | Get-ChildItem -File -Recurse -Filter *$fileNamePart* | Where-Object Name -match '(?:\.help\.txt|-help.xml)$'}# Find help source files whose name contains 'about_psreadline'Get-HelpFile about_psreadlineYou can pass any substring contained in help file names, such as module names, e.g. PSReadLine, but note that this won't necessarily show all help files associated with that module, given that conceptual help topics don't necessarily contain the name of the module they're associated with.Also, some module names aren't reflected in their help file names, notably module Microsoft.PowerShell.Core (help file name is System.Management.Automation.dll-Help.xml) and Microsoft.PowerShell.Management (help file name is Microsoft.PowerShell.Commands.Management.dll-Help.xml).If you pipe the above command to | Select FullName, Length, it will list the file size in bytes (property .Length) alongside the full path, which can be correlated with the sizes reported by, e.g., Get-Help about_PSReadLine | Select Length, so as to infer the order in which the topics are being listed. 这篇关于重复的HelpFiles(about_)阻止Get-Help显示信息.如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-20 18:29