Powershell 2.0在帮助页面中呈现脚本的默认参数值需要什么?

Ste*_*idi 5 powershell default-value powershell-2.0

我有以下简单的脚本,它接受文本作为输入并将其写入主机.

<#
.SYNOPSIS
    Writes the input string to the host.
.PARAMETER Text
    The text to write to the host.
#>

param([string]$text = "hello world!")
Write-Host $text
Run Code Online (Sandbox Code Playgroud)

要呈现此脚本的帮助,我在Powershell会话中执行以下命令,其中write-text.ps1是此脚本的名称.

get-help .\write-text.ps1 -full
Run Code Online (Sandbox Code Playgroud)

在下面的输出中,我希望看到帮助中列出的脚本参数的默认值 - 但我没有:

PARAMETERS
    -text <String>
        The text to write to the host.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?
Run Code Online (Sandbox Code Playgroud)

我需要在此脚本中添加或更改帮助引擎以呈现默认参数值?

Jas*_*her 5

您无法使用基于注释的帮助显示默认值.您需要制作MAML帮助文件才能执行此操作.