Powershell脚本默认值未显示在“获取帮助-完整”中

Powershell脚本默认值未显示在“获取帮助-完整”中,powershell,parameters,Powershell,Parameters,我正在尝试设置PowerShell命令,因此Get Help-full将显示有关如何运行脚本的完整信息。我有要在此帮助中显示的默认值。我有以下资料: <# .PARAMETER SenderEmail The name of the user who is sending the email message. Although not officially required, it will be checked to make sure it's not blan

我正在尝试设置PowerShell命令,因此
Get Help-full
将显示有关如何运行脚本的完整信息。我有要在此帮助中显示的默认值。我有以下资料:

<#
    .PARAMETER SenderEmail
    The name of the user who is sending the email message. Although not
    officially required, it will be checked to make sure it's not blank.
#>

Param (

   [String]
   [Parameter(
        Position=1,
        HelpMessage="Sender's Email Address")]
   $SenderEmail = "bob@fubar.com"
)

我认为您无法在V2的高级函数中获得显示的默认值。我甚至尝试过[System.ComponentModel.DefaultValueAttribute(“”),但没有成功。然而,如果有什么安慰的话,这似乎和V3一样有效

V3 ONLY!!
PS> Get-Help .\help.ps1 -full

NAME
    C:\temp\help.ps1

SYNOPSIS

SYNTAX
    C:\temp\help.ps1 [[-SenderEmail] <String>] [<CommonParameters>]


DESCRIPTION


PARAMETERS
    -SenderEmail <String>
        The name of the user who is sending the email message. Although not
        officially required, it will be checked to make sure it's not blank.

        Required?                    false
        Position?                    2
        Default value                bob@fubar.com
        Accept pipeline input?       false
        Accept wildcard characters?  false

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

INPUTS

OUTPUTS


RELATED LINKS
V3仅限!!
PS>获取帮助。\Help.ps1-完整
名称
C:\temp\help.ps1
提要
语法
C:\temp\help.ps1[[-SenderEmail]][]
描述
参数
-发送邮件
发送电子邮件的用户的名称。虽然不是
官方要求,它将被检查,以确保它不是空白的。
必修的?假的
位置?2.
默认值bob@fubar.com
接受管道输入?假的
是否接受通配符?假的
此cmdlet支持常用参数:详细、调试、,
ErrorAction,ErrorVariable,WarningAction,WarningVariable,
突发的和不稳定的。有关详细信息,请参阅
关于公共参数(http://go.microsoft.com/fwlink/?LinkID=113216). 
投入
输出
相关链接

似乎没有办法指定参数的默认值。您需要在参数的描述中指定它

<#
.PARAMETER SenderEmail
The name of the user who is sending the email message. If not 
specified, a default value of bob@fubar.com will be used
#>

如@KeithHill所述,在下一次修订中似乎已修复。谢谢您的回复。我想当我们升级到Windows7时我们会看到的。谢谢你的链接。自从基思希尔第一个回答后,我就给了他正确的答案。不过,我会为你修改一个链接点。
<#
.PARAMETER SenderEmail
The name of the user who is sending the email message. If not 
specified, a default value of bob@fubar.com will be used
#>
Default values and a value for "Accept Wildcard characters" do not appear in
the parameter attribute table even when they are defined in the function or
script. To help users, provide this information in the parameter description.