I've a simple powershell script below which basically executes the abc.exe (console application) with few arguments.
& abc.exe ar1 ar2
abc.exe file is .net so it has it's own exception handler.
Whenever abc.exe throws exception I would like the Powershellscript to catch and log/echo.
Could someone help me how to achieve above.
No.
The exception in abc.exe will bubble up to main method, not any more. But you can check the ERRORLEVEL of abc.exe by looking at $LASTEXITCODE. (Check this)
What you should do:
Additionally, you can also use different exitcodes for errorlevels in abc.exe to provide some information to PowerShell script. For example these are 7zip error levels.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With