title: Catch all Powershell errors using Try/Catch/Finally
body: <p>I have a 1500+ lines Powershell script that has been enhanced to log progress and errors to Azure Table Storage.</p>
  
  <p>The problem is that not all errors are logged.</p>
  
  <p>Is this the easiest way to accomplish this without changing the script too much and catching all errors?</p>
  
  <pre><code>$ErrorActionPreference = "Stop"
  
  function a
  {
      "a"
  }
  
  function b
  {
      "b"
      Get-Content foo
  }
  
  function c
  {
      "c"
  }
  
  Try
  {
      a
      b
      c
  }
  Catch
  {
      "Catch &amp; Log Error"
      $Error[0].Exception
  }
  Finally
  {
      "The End"
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The output is:</p>
  
  <pre><code>a
  b
  Catch &amp; Log Error
  Cannot find path 'C:\foo' because it does not exist.
  The End
  </code></pre>