如何使用Start-job将多个变量作为参数传递给脚本

Nav*_*een 8 powershell powershell-2.0

如何使用Start-job将多个变量作为参数传递给脚本.

  Start-Job -Name "$jobName" -filepath $TestTool -ArgumentList $compare1
Run Code Online (Sandbox Code Playgroud)

如何在脚本TestTool.ps1中检索此参数值($ arg1和$ arg2)?

Rgds Naveen

Loï*_*HEL 10

 PS>Start-Job -Name test -ArgumentList @("hello","word") -FilePath \\server\share\test.ps1
Run Code Online (Sandbox Code Playgroud)

在test.ps1中只是回显$ args var

   $args
Run Code Online (Sandbox Code Playgroud)

结果:

PS>Receive-Job test -keep
hello
word
Run Code Online (Sandbox Code Playgroud)


dst*_*zak 3

http://technet.microsoft.com/en-us/library/hh849698.aspx

“由于 ArgumentList 参数名称后面的所有值都被解释为 ArgumentList 的值,因此 ArgumentList 参数应该是命令中的最后一个参数。”

所以我猜想是这样的:

... -ArgumentList $arg1 $arg2
Run Code Online (Sandbox Code Playgroud)

应该管用?