title: Error Handling for Invoke-RestMethod - Powershell
body: <p>I have a powershell script using the Skytap API (REST). I would like to catch the error, if there is one, and try to display it.</p>
  
  <p>For example, we are changing the IP:</p>
  
  <pre><code>Invoke-RestMethod -Uri https://cloud.skytap.com/configurations/XXXXXX/vms/YYYYYY/interfaces/ZZZZZZ?ip=10.0.0.1 -Method PUT -Headers $headers
  </code></pre>
  
  <p>If the IP is used somewhere else, I will get the 409 Conflict Error (Request is well-formed but conflicts with another resource or permission). </p>
  
  <p>I would like to check if the error is 409 and then tell it to do something else about it.</p>