1
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')

Hi guys, how can i pass $a as an array in remote session ????.

PowerShell
  • 1,991
  • 8
  • 35
  • 57

1 Answers1

2

One way:

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

1
2
3
mjolinor
  • 66,130
  • 7
  • 114
  • 135