Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 禁用Powershell中的位置参数绑定_Windows_Powershell - Fatal编程技术网

Windows 禁用Powershell中的位置参数绑定

Windows 禁用Powershell中的位置参数绑定,windows,powershell,Windows,Powershell,我只想通过别名获取参数: script.ps1-d站点1-c eac34b2d 这是不允许的: script.ps1站点1 eac34b2d 基本上,您希望禁用位置参数绑定。我在Powershell 3.0中介绍了一种内置方式:使用[CmdletBinding(positionbinding=$false)] 此处提供了v2的解决方案: 真不错。正是我需要的。 Param( [parameter(Mandatory=$true)] [alias("d")] $DocRo

我只想通过别名获取参数:

script.ps1-d站点1-c eac34b2d

这是不允许的:

script.ps1站点1 eac34b2d


基本上,您希望禁用位置参数绑定。我在Powershell 3.0中介绍了一种内置方式:使用
[CmdletBinding(positionbinding=$false)]

此处提供了v2的解决方案:


真不错。正是我需要的。
Param(
    [parameter(Mandatory=$true)]
    [alias("d")]
    $DocRoot,
    [alias("c")]
    $Commit
)