Tob*_*KKS 4 powershell powershell-module
从我创建并导入到主脚本中的模块调用函数时出现此错误:
Run-RemoteScript : Cannot bind argument to parameter 'Targets' because it
is an empty string.
At C:\Scripts\Script.ps1:114 char:39
+ Run-RemoteScript -Targets $targets -RunMethod $runMethod ...
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Run-RemoteScript],
ParameterBindingValidationException
+ FullyQualifiedErrorId :
ParameterArgumentValidationErrorEmptyStringNotAllowed,Run-RemoteScript`
Run Code Online (Sandbox Code Playgroud)
在我的模块中,-Target被定义为这样的参数:
[Parameter(Mandatory, Position = 0)][String[]]$Targets,
Run Code Online (Sandbox Code Playgroud)
在我的主脚本(导入我的模块)中,$targets定义如下:
$Targets = Set-TargetList
Run Code Online (Sandbox Code Playgroud)
我曾尝试使用global脚本范围,但这不起作用。
可能是一个迟到的答案,但以防其他人有类似的问题。
就我而言,它是一个字符串数组。当至少一个成员字符串为空或为空时,它被拒绝。
AllowEmptyString在您调用的参数中设置为属性,或者在传递成员之前检查成员是否不是空字符串。
| 归档时间: |
|
| 查看次数: |
6569 次 |
| 最近记录: |