2012-04-11 15 views
3

PowerShellコマンドをセットアップしようとしています。そのため、Get-Help -fullにスクリプトの実行方法に関する完全な情報が表示されます。このヘルプに表示するデフォルト値があります。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 = "[email protected]" 
) 

ただし、Get-Help -detailと入力すると、次のように表示されます。

-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? 

このパラメータのデフォルト値を表示するにはどうすればよいですか?

答えて

3

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    [email protected] 
     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 
+0

おかげで述べたように次のリビジョンで修正されるのを見えます。私はWindows 7にアップグレードするときにそれを見るだろうと思う。 –

4

パラメータのデフォルト値を指定する方法はないようです。パラメータの説明で指定する必要があります。

<# 
.PARAMETER SenderEmail 
The name of the user who is sending the email message. If not 
specified, a default value of [email protected] 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

ご返信用
+0

リンクをありがとう。彼は最初に答えたので、私は正しい答えをKeithHillに与えました。しかし、私はリンクのポイントを改造します。 –

関連する問題