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

1
  • your question is not very clear Commented Nov 14, 2012 at 10:09

2 Answers 2

11
 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
Sign up to request clarification or add additional context in comments.

Comments

4

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?

2 Comments

how to retrieve this argument values (of $arg1 and $arg2) in a script TestTool.ps1?
Number of arguments - $args.lenghth. First argument: $args[0], second: $args[1], etc.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.