Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 897
Naveen Avatar asked Nov 14 '12 09:11

Naveen


2 Answers

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

in test.ps1 just echo the $args var

   $args

result :

PS>Receive-Job test -keep
hello
word
like image 54
Loïc MICHEL Avatar answered Oct 14 '22 01:10

Loïc MICHEL


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

"Because all of the values that follow the ArgumentList parameter name are interpreted as being values of ArgumentList, the ArgumentList parameter should be the last parameter in the command."

So I guess tha something like:

... -ArgumentList $arg1 $arg2

should work?

like image 28
dstronczak Avatar answered Oct 14 '22 01:10

dstronczak