从powershell脚本中运行powershell脚本

从powershell脚本中运行powershell脚本,powershell,parallel-processing,invoke-command,start-job,Powershell,Parallel Processing,Invoke Command,Start Job,我有一个perl脚本perl1.pl。 在perl脚本中,我将powershell脚本称为script1.ps1。 在script.ps1中,我使用局部变量作为参数调用其他脚本,如script2.ps1。 我已经准备了一个powershell脚本script3.ps1。 我想从script1.ps1与script2.ps1并行运行script3.ps1。 我需要传递sample_script2.ps1运行时使用的参数(局部变量作为参数)。 首先需要调用script3,然后调用script2 我尝

我有一个perl脚本perl1.pl。 在perl脚本中,我将powershell脚本称为script1.ps1。 在script.ps1中,我使用局部变量作为参数调用其他脚本,如script2.ps1。 我已经准备了一个powershell脚本script3.ps1。 我想从script1.ps1与script2.ps1并行运行script3.ps1。 我需要传递sample_script2.ps1运行时使用的参数(局部变量作为参数)。 首先需要调用script3,然后调用script2

我尝试过powershel.exe,如下所示

C:..\powershell.exe-文件路径script3.ps1$a、$b、$C

我已经包括了旁路,执行策略。$a$b$c是局部变量。但似乎发生的是命令行打开(这是我们脚本的调用方式)并开始执行script1.ps1,当涉及到上述命令时,它停止。我在上述命令行中键入“exit”,然后script2开始


如何实现与script2.ps1相同的并行运行(即script3.ps1和script2.ps1)。

我不太了解PowerShell,但我知道您可以运行

当cmdlet作为后台作业运行时,该工作将在其自己的线程中异步完成

要用于创建后台作业的cmdlet(command-let)为

此命令将Sample.ps1脚本作为后台作业运行。然后,您可以使用
Receive Job
从所有作业中获取输出

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