title: Switching on SqlException.Number in Powershell
body: <p>I have this catch block in my Powershell script.</p>
  
  <pre><code>catch [System.Data.SqlClient.SqlException]
  {
     Write-Host "$_"
     Exit 2
  }
  </code></pre>
  
  <p>I would really like to be able to switch on the error number.
  I know atleast in C# there's a property on the SqlException called number. Isn't that also true for Powershell?</p>
  
  <p>If the property is there, how do I access it?</p>
  
  <p>Thank you very much in advance</p>