Reputation: 293
Am creating a powershell script for Biztalk deployment. I wrote a normal try catch block to handle the exceptions during the deployment. My Code was able to catch the Exceptions like
# File Not Found
# Syntax Errors
But exception like Dependency applications needs to be installed before installing
- was not getting caught. But when i check the Powershell console i can see..
CommandExecuted with 1 Error
.
Please Suggest how to handle these exceptions.
Upvotes: 0
Views: 331
Reputation: 202042
In addition to non-terminating errors, you should be aware that PowerShell try/catch does not "catch" the fact that an executable returned an error exit code. You can make it generate an exception like so:
some.exe someargs
if ($LastExitCode -ne 0) { throw "some.exe failed with exit code $LastExitCode" }
Upvotes: 2