【发布时间】:2020-06-28 12:13:47
【问题描述】:
我正在编写一个使用 ValueFromRemainingArguments 包装 cmdlet 的函数(如 here 所述)。
下面的简单代码演示了这个问题:
- 作品
function Test-WrapperArgs {
Set-Location @args
}
Test-WrapperArgs -Path C:\
- 不起作用
function Test-WrapperUnbound {
Param(
[Parameter(ValueFromRemainingArguments)] $UnboundArgs
)
Set-Location @UnboundArgs
}
Test-WrapperUnbound -Path C:\
Set-Location: F:\cygwin\home\thorsten\.config\powershell\test.ps1:69
Line |
69 | Set-Location @UnboundArgs
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| A positional parameter cannot be found that accepts argument 'C:\'.
我尝试从PowerShell Community Extensions 解决GetType 和EchoArgs 的问题,但无济于事。目前我几乎正在考虑一个错误(可能与this ticket??有关)。
【问题讨论】:
标签: powershell parameters wrapper