7

エイリアスを介してのみパラメータが必要です:

script.ps1 -d site1 -c eac34b2d

これは許可されるべきではありません:

script.ps1 site1 eac34b2d

Param(
    [parameter(Mandatory=$true)]
    [alias("d")]
    $DocRoot,
    [alias("c")]
    $Commit
)
4

1 に答える 1

6

基本的に、位置パラメータのバインドを無効にします。Powershell 3.0に組み込まれている方法について書きました:use [CmdletBinding(PositionalBinding=$false)]

http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2011/09/19/how-to-disable-positional-parameter-binding-in-powershell.aspx

v2の回避策は、次の場所にあります。

http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/abbc587f-cd7e-4c8d-879f-355339d9d6b7/

于 2012-09-11T17:58:06.870 に答える