Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Capturing log files from multiple .ps1 scripts called from within a .bat file

$
0
0

I am trying to invoke multiple instances of a powershell script and capture individual log files from each of them. I can start the multiple instances by calling 'start powershell' several times, but am unable to capture logging. If I use 'call powershell' I can capture the log files, but the batch file won't continue until that current 'call powershell' has completed.

ie.  within Test.bat

start powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > a.log 2>&1
timeout /t 60
start powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > b.log 2>&1
timeout /t 60
start powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > c.log 2>&1
timeout /t 60
start powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > d.log 2>&1
timeout /t 60
start powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > e.log 2>&1
timeout /t 60
start powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > f.log 2>&1

the log files get created but are empty.  If I invoke 'call' instead of start I get the log data, but I need them to run in parallel, not sequentially.

call powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > a.log 2>&1
timeout /t 60
call powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > b.log 2>&1
timeout /t 60
call powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > c.log 2>&1
timeout /t 60
call powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > d.log 2>&1

timeout /t 60call powershell . \Automation.ps1 %1 %2 %3 %4 %5 %6 > e.log 2>&1
Any suggestions of how to get this to work?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>