Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a perl script perl1.pl. Within the perl script I call a powershell script script1.ps1. In script.ps1 I call other script like script2.ps1 with local variables as parameters. I have prepared a powershell script script3.ps1. I want to run script3.ps1 from script1.ps1 in parallel with script2.ps1. I need to pass same arguments(local variables as argument) that sample_script2.ps1 runs with. First script3 needs to be called then script2.

I have tried powershel.exe like follows

C:..\powershell.exe -FilePath script3.ps1 $a,$b,$c

I have included bypass ,execution policy.$a $b $c are local variables.But what seems to happen is the command line opens(as it is the way our scripts are called) and starts executing script1.ps1 and when it comes to above mentioned command it stops.I type in "exit" in the above command line and then script2 starts.

How can I achieve the same i.e parallel run of script3.ps1 with script2.ps1.

share|improve this question

1 Answer 1

I'm not too PowerShell savvy but I know you can run background jobs in PowerShell.

When a cmdlet runs as a background job, the work is done asynchronously in its own thread ...

The cmdlet (command-let) you want to use to create a background job is Start-Job.

Start-Job -FilePath c:\scripts\sample.ps1

This command runs the Sample.ps1 script as a background job. Then you can use Receive-Job to get the out put from all your jobs.

Similar Question?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.