title: How to catch an exception thrown in another Powershell script?
body: <p>I have a two Powershell scripts; main.ps1 and sub.ps1. main.ps1 calls sub.ps1. Sometimes sub.ps1 throws an exception. Is it  possible to catch the exception thrown by sub.ps1 from main.ps1 ?</p>
  
  <p>Example main.ps1:</p>
  
  <pre><code>try{. .\sub.ps1;}
  catch
  {}
  finally
  {}
  </code></pre>
  
  <p>Example sub.ps1:</p>
  
  <pre><code>throw new-object System.ApplicationException "I am an exception";
  </code></pre>