9

How to pass Multiple Variables as Arguments to a Script using Start-job.

  Start-Job -Name "$jobName" -filepath $TestTool -ArgumentList $compare1

how to retrieve this argument values (of $arg1 and $arg2) in a script TestTool.ps1?

Rgds Naveen

4

2 回答 2

11
 PS>Start-Job -Name test -ArgumentList @("hello","word") -FilePath \\server\share\test.ps1

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

   $args

结果 :

PS>Receive-Job test -keep
hello
word
于 2012-11-14T10:15:24.150 回答
3

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

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

所以我猜想是这样的:

... -ArgumentList $arg1 $arg2

应该管用?

于 2012-11-14T09:27:49.167 回答