Powershell 4.0 – Try/Catch Exchange 2010 Bug?

I’ve been struggling some time now on why Powershell 4.0 are unable to “Catch” terminating errors when using Exchange 2010 Cmdlets.

When using a standard “Set-Mailbox” with Erroraction set to Stop using Powershell 3.0 the terminating error is validated by the “Try/Catch”-block:

Error with Set-Mailbox

When we use Powershell 4.0 with the same “Try/Catch”-block the result will be:

The operation couldn’t be performed because object ‘NoMailbox’ couldn’t be found on ‘DC01.contoso.com’.
+ CategoryInfo          : NotSpecified: (0:Int32) [Set-Mailbox], ManagementObjectNotFoundException
+ FullyQualifiedErrorId : 7780025A,Microsoft.Exchange.Management.RecipientTasks.SetMailbox
+ PSComputerName        : EX2010.contoso.com

A workaround for this is to use the $ErrorActionPreference variable:

Error with Set-Mailbox

Found an old thread on Technet touching this subject: Technet Forum
My speculation is whether this is a bug in the remote management of PowerShell 4.0 with Exchange 2010 Cmdlets or if it’s by design.
Either way the workaround works!

I haven’t tested this with Powershell 5.0. If you have please enlighten me if it works as it should like Powershell 3.0