почему блок сценария, переданный в качестве аргумента в списке аргументов invoke-commands, терпит неудачу?

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
6
задан JasonMArcher 24 August 2011 в 19:11
поделиться