Powershell Script The default value does not appear in Get-Help -full

I am trying to customize my PowerShell command, so it Get-Help -fullwill show full information on how to run my script. I have default values ​​that I want to display in this help. I have the following:

<#
    .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 not blank.
#>

Param (

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

However, when I type Get-Help -detail, the following appears.

-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 not blank.

    Required?                    false
    Position?                    2
    Default value
    Accept pipeline input?       false
    Accept wildcard characters?

How do I get help to show the default value of this parameter?

+3
source share
2 answers

, 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 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
+3

, . .

<#
.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
#>

http://technet.microsoft.com/en-us/library/dd819489.aspx.

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.

, , @KeithHill

+4

All Articles