B
B
Berkutman2019-10-01 20:15:53
PowerShell
Berkutman, 2019-10-01 20:15:53

How to run scripts in parallel in powershell?

There is a script conf.ps1
It has variables that are then passed to other scripts and executed from conf.ps1
How to execute scripts from a script in parallel to each other in powershell ?
Now Script1.ps1 is executed first after Script2.ps1,
I need the scripts to run in parallel, or better yet, open a new Powershell window and from there watch the process of each of the scripts
./Script1.ps1 -SERVER $SERVERLIN[0] -LOGINSERVER $LOGINSERVERLIN[0] -PASSSERVER $PASSSERVERLIN[0] -PATHLIN $PATHLIN -NAMELIN $NAMELIN[0] -DATA $DATA
./Script2.ps1 -SERVER $SERVERLIN[1] -LOGINSERVER $LOGINSERVERLIN[0] -PASSSERVER $PASSSERVERLIN [1] -PATHLIN $PATHLIN -NAMELIN $NAMELIN[1] -DATA $DATA

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
azarij, 2019-10-01
@azarij

start job?

A
Alexander, 2019-10-18
@Sanyum

$job = Start-Job -name myjob -ScriptBlock {
    param(
      $param1,
      $param2
    );
#
# тут что-нибудь делаем
#
} -ArgumentList $arg1,$arg2

if ($wpJob.State -eq "Completed") {
    Receive-Job $wpJob;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question