Enable-RemoteMailbox cmdlet not handling non terminating errors

Hello,

I'm using Enable-RemoteMailbox cmdlet and I wanted to handle non-terminating exceptions generated by the cmdlet. I searched '-ErrorAction Stop' parameter and used with Enable-RemoteMailbox cmdlet but no luck.

Someone please help me out on this.

Appreciate the help

Parents
  • I have dealt with some idiosyncrasies like this myself.

    I presume you are using a Try/Catch with your Enable-RemoteMailbox command?

    You said you tried explicitly using -ErrorAction Stop and are not happy with the result.  Can you elaborate?

    What sort of error condition are you trying to trap that is non-terminating?  




Reply
  • I have dealt with some idiosyncrasies like this myself.

    I presume you are using a Try/Catch with your Enable-RemoteMailbox command?

    You said you tried explicitly using -ErrorAction Stop and are not happy with the result.  Can you elaborate?

    What sort of error condition are you trying to trap that is non-terminating?  




Children
  • I'm running Enable-RemoteMailbox command on the user account already having remote mailbox. I've to track such issue if arises and issue description is follows but this error is not handling in the catch block as it is non terminating error.

    This task does not support recipients of this type. The specified recipient nammcal.local/InlandValley/O365 Thursday is of type RemoteUserMailbox. Please make sure that this recipient matches the required recipient type for this task

    I found -ErrorAction parameter and i tried to append it to 'Enable-RemoteMailbox' cmdlet but still its not handled by catch block. 

    Here is the code snippet, with or without -ErrorAction parameter code behaves same.

    try{Enable-RemoteMailbox $acc.SamAccountName -RemoteRoutingAddress $routeAddress -ErrorAction Stop
    }
    catch
    {
    echo "Catch"
    }