小编Chr*_*ton的帖子

基于注释的帮助的正确语法.EXAMPLE

根据 Powershell 帮助文件 (Get-Help about_comment_based_help) 中的信息,以下代码应该有效:

<#
    .EXAMPLE
        PS C:\> .\help_test.ps1
#>
Run Code Online (Sandbox Code Playgroud)

运行Get-Help .\help_test.ps1 -full时的预期输出应该是:

PS C:\Users\cbarton\Desktop\github\Powershell> Get-Help .\help_test.ps1 -full

NAME
    C:\Users\cbarton\Desktop\github\Powershell\help_test.ps1

SYNOPSIS


SYNTAX
    C:\Users\cbarton\Desktop\github\Powershell\help_test.ps1 [<CommonParameters>]


DESCRIPTION


PARAMETERS
    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS

    -------------------------- EXAMPLE 1 --------------------------

    PS C:\> .\help_test.ps1







RELATED LINKS
Run Code Online (Sandbox Code Playgroud)

然而,根据我的经验,我无法以同样的方式显示我的示例。相反,示例的命令部分与路径连接,并删除了所有空格。

OUTPUTS

    -------------------------- EXAMPLE 1 --------------------------

    PS C:\>.\help_test.ps1
Run Code Online (Sandbox Code Playgroud)

是我做错了什么,还是所有 Microsoft 示例都错了?

PS C:\Users\cbarton\Desktop\github\Powershell> $psversiontable

Name                           Value
---- …
Run Code Online (Sandbox Code Playgroud)

powershell

5
推荐指数
1
解决办法
193
查看次数

标签 统计

powershell ×1