Powershell Script Default Value not showing up in Get-Help -full

parameters, powershell

Solution

I don't think you can get the default value to display in an advanced function in V2. I've even tried [System.ComponentModel.DefaultValueAttribute("")] with no luck. However, if it's any consolation, this appears to work as-is in 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

Problem

I am trying to setup my PowerShell command, so the `Get-Help -full` will show complete information about 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's not blank. #> Param ( [String] [Parameter( Position=1, HelpMessage="Sender's Email Address")] $SenderEmail = "bob@fubar.com" ) ``` Yet, when I type Get-Help -detail, the following shows up. ``` -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 Accept pipeline input? false Accept wildcard characters? ``` How do I get the help to show the default value of this parameter?

Original source