try catch not working

I wrote a custom powershell script and have it run in a workflow.

I'm having an issue with the try catch statement. If I remove try catch and just run the command inside the try method, the workflow executes fine. However, when a try catch is added, the commands inside the try method do not execute. Anyone have an answer to this issue?

try {
    Send-MailMessage -From $From `
        -Subject $Subject `
        -To $To `
        -BodyAsHtml $Body `
        -SmtpServer $Smtp `
        -Attachments $Report `
        -ErrorAction Stop
    }
catch {}

Parents Reply Children
  • The error action does work for the send-mail cmdlet as I've ran it multiple times in stand alone scripts outside of Active Roles workflows. If it errors, the catch statement always catches. If it doesn't error, the message goes out as intended. 

    However, with the workflow, there is no indication of error and no message ever goes out. The workflow ends as if it completed successfully.