function test-scriptblock {
1..10 }
function caller ([scriptblock]$runthis) {
& $runthis
}
以下工作正常。
caller -runthis ${function:test-scriptblock}
这不起作用
invoke-command -ComputerName localhost -ScriptBlock ${function:caller} -ArgumentList ${function:test-scriptblock}
Cannot process argument transformation on parameter 'runthis'. Cannot convert the "
1..10 " value of type "System.String" to type "System.Management.Automation.ScriptBlock".
+ CategoryInfo : InvalidData: (:) [], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError