title: Exception not caught when using PowerShell command line but caught as expected when using PowerShell ISE
body: <p>I am running PowerShell 2.0.</p>
  
  <p>I have a PowerShell script that adds a record to the database and returns the ID of the record added.
  The record ID is returned as a property called <code>new_deal_id</code> within a DataRow object (called <code>ResultSet</code>).</p>
  
  <p>If there is a problem on the database end it is possible that the <code>new_deal_id</code> property does not get set, or doesn't exist at all.</p>
  
  <p>To counter this scenario I wrapped the reading of the property in a try/catch block as shown here.</p>
  
  <pre><code>try {
      $ErrorActionPreference = "Stop"
      $ResultSet = Read-DatabaseData -OdbcCommand $OdbcCommand -SqlQuery $Sql
      $NewDealID = $ResultSet.new_deal_id
  }
  catch {
      throw
  }
  finally {
      $ErrorActionPreference = "Continue"
  }
  </code></pre>
  
  <p>If I run the script using the PowerShell ISE or PowerGui the exception shown below gets caught when the property doesn't exist</p>
  
  <pre><code>Property 'new_deal_id' cannot be found on this object. Make sure that it exists.
  At line:1 char:12
  + $ResultSet. &lt;&lt;&lt;&lt; newdeal
      + CategoryInfo          : InvalidOperation: (.:OperatorToken) [], ParentContainsErrorRecordException
      + FullyQualifiedErrorId : PropertyNotFoundStrict
  </code></pre>
  
  <p>However if I run the script from the PowerShell command line the exception does not get caught and the script continues as if no error occurred.</p>
  
  <p>Why is the PowerShell command line not catching the exception when the property doesn't exist?</p>