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