gpt4 book ai didi

Powershell 脚本默认值未显示在 Get-Help -full 中

转载 作者:行者123 更新时间:2023-12-04 17:54:51 25 4
gpt4 key购买 nike

我正在尝试设置我的 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"
)

然而,当我输入 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?

如何获得帮助以显示此参数的默认值?

最佳答案

我认为您无法获得默认值以在 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

关于Powershell 脚本默认值未显示在 Get-Help -full 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10110879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com