在PowerShell远程会话中传递数组

时间:2014-03-07 14:53:04

标签: powershell

Invoke-Command -ComputerName Server01 -ScriptBlock {
param ($first)

Write-Output "The value of `$a is: $first"
} -ArgumentList $a

The value of $a is: @('1','2','3')

大家好,我怎样才能在远程会话中传递$ a作为数组????。

1 个答案:

答案 0 :(得分:1)

一种方式:

Invoke-command -ScriptBlock {param($first) Write-output $first} -argumentlist @(,(1,2,3))

1
2
3