How to check result of calling SVN from Powershell


I`m trying to automate a branching operation using a Powershell script like the following:

As long as the call to SVN works, this should work fine; what I’d like however, is to capture the result, and stop the script with an error message if the call fails. The script above obviously fails because of invalid URLs, but the result is not captured in $copyResult and $switchResult, as I would have expected. The resulting output is instead as follows; the status-messages are shown before the output of my two result variables, and they are empty:

This differs from a few other calls I’m making, where the output result can be captured in a variable and checked later.

Is there any way to achieve this for these two calls as well?


The exit code of an external command is stored in the $LastExitCode environment variable. If you want the script to stop in case of an error, you should check that variable:

I’d recommend capturing regular and error output in log files rather than variables, though:


How to check result of calling SVN from Powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply