title: How to send an email notification when PowerShell script gets an error?
body: <p>I have a PS script that works automatically on task scheduler, at the end of the script there is an email confirming that the script was successful, if the script gets one error during its process the script stops ($ErrorActionPreference = "Stop"), this avoids the script to get to the point when the confirmation email is sent. But, I cant send an email when there is an error to notify someone about this error. </p>
  
  <p>What can be a solution for this?</p>
  
  <p>Thank you!</p>