我可以从PowerShell中基于注释的帮助中隐藏某些注释吗?

我可以从PowerShell中基于注释的帮助中隐藏某些注释吗?,powershell,syntax,comments,Powershell,Syntax,Comments,我目前正在编写一个PowerShell脚本,用于审计我们广告结构中的过时计算机对象并对其采取行动。为了成为一名优秀的脚本编写者,我正在实现基于注释的帮助。它正在工作,但我尝试使用注释参数的语法,它们会自动显示在帮助的.PARAMETERS部分下 如果可以避免的话,我不想在适当的基于注释的帮助注释代码中使用单独的.PARAMETERS部分,以便注释在物理上保留在参数中。但是如果没有办法避免我的问题,那么我想我不得不这样做 问题是我的一些参数使用了验证,我已经对验证代码的一些部分进行了注释。但是,基

我目前正在编写一个PowerShell脚本,用于审计我们广告结构中的过时计算机对象并对其采取行动。为了成为一名优秀的脚本编写者,我正在实现基于注释的帮助。它正在工作,但我尝试使用注释参数的语法,它们会自动显示在帮助的
.PARAMETERS
部分下

如果可以避免的话,我不想在适当的基于注释的帮助注释代码中使用单独的
.PARAMETERS
部分,以便注释在物理上保留在参数中。但是如果没有办法避免我的问题,那么我想我不得不这样做

问题是我的一些参数使用了验证,我已经对验证代码的一些部分进行了注释。但是,基于注释的帮助包括所有这些杂项。评论,我宁愿它没有,因为它混乱了get-help输出,没有增加任何价值

下面是代码的摘录:

function audit-StaleADComputersInOU {
<#
.SYNOPSIS
Exports a list of AD Computer objects to the screen, and optionally to a CSV formatted file.
Optionally take other actions on returned objects.
Results are from one or more given OU DNs, and filtered by LastLogonTimeStamp.

.OTHER COMMENT-BASED HELP SECTIONS
etc. etc., not including .PARAMETERS
#>


    [CmdletBinding(SupportsShouldProcess=$true)]

    param(
        # Specify the full filepath to a file.
        # Results will be exported in CSV format to that file.
        # Parent directory must exist.
        # Omit to export nothing and create no file.
        [ValidateScript({
            # Parent directory
            $path = Split-Path -Path $_

            # Check parent directory exists
            if(!(Test-Path $path)) {
                throw "$path directory doesn't exist!"
            }
            # Check parent directory is actually a directory
            if(!(Test-Path $path -PathType Container)) {
                throw "$path is not a directory!"
            }
            # Check file doesn't already exist
            if(Test-Path $_){
                throw "$_ already exists!"
            }
            return $true
        })]
        [System.IO.FileInfo]
        $ExportToCSV,

        # Other params, etc.
    )

    # Doing stuff
}

有没有办法避免这种情况?我可以使用任何注释语法使特定注释对基于注释的帮助不可见吗?或者,我唯一的选择是将我想要的注释提取到脚本顶部基于注释的帮助语法的
.PARAMETERS
部分吗?

由于您使用其他基于注释的帮助部分,而不是
。parameter
对于该参数。在这种情况下,
Get Help
所做的是假设参数上方的注释应该是描述

要阻止这种情况发生,必须在每个参数的基于注释的主帮助中包含一个
.PARAMETER
。除了从参数中删除注释外,没有其他方法。您不需要参数的描述,尽管我建议添加一个

<#
.SYNOPSIS
Exports a list of AD Computer objects to the screen, and optionally to a CSV formatted file.
Optionally take other actions on returned objects.
Results are from one or more given OU DNs, and filtered by LastLogonTimeStamp.

.OTHER COMMENT-BASED HELP SECTIONS
etc. etc., not including .PARAMETERS

.PARAMETER ExportToCSV
#>

以上内容将确保有关参数的注释不会包含在帮助中。如果您需要描述,请将其放在下面,就像其他基于注释的帮助部分一样


参考资料:

我就是这么想的。谢谢
<#
.SYNOPSIS
Exports a list of AD Computer objects to the screen, and optionally to a CSV formatted file.
Optionally take other actions on returned objects.
Results are from one or more given OU DNs, and filtered by LastLogonTimeStamp.

.OTHER COMMENT-BASED HELP SECTIONS
etc. etc., not including .PARAMETERS

.PARAMETER ExportToCSV
#>