Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Getting the output of a batchfile to Powershell

$
0
0

Greetings. I have a list of batchfiles that triggers Powershell script, that will throw error message when different errors were encountered in the execution. 

In the end of the batchfile, I have included:

if%errorlevel% neq 0(echo errorin previous command &exit/b %errorlevel%)

and it works fine in itself. 

However due to some requirements I need to use new separate batchfile that triggers a Powershell, that will in turn lauch the batchfiles mentioned earlier. 

In the new Powershel, I have included: 

$process = start-process $batchFile.FullName -ArgumentList $argumentList -PassThru -Wait 

and is able to get $process.ExitCode. However I would like to get the output or error message that would be raised from the first batchfile instead. 

Any advice?


Viewing all articles
Browse latest Browse all 6937

Trending Articles