Powershell 5 ErrorAction Stop

I have a script I’ve been using for a while in PS 4, but after upgrading to Windows 10 “-ErrorAction Stop” is not working with try/catch.

This is a basic part of the code that is not working
try {
$mbx = Get-Mailbox $UserID -ErrorAction Stop

}
catch {
$mbx = Get-RemoteMailbox $UserID

}

The error is showing as if there was no EA action defined. If I replace Stop for SilentlyContinue, it works as expected, but I need the Stop switch so I can work with try/catch.

Any ideas?

I haven’t used the Exchange module much personally, but I’ve seen comments about -ErrorAction being flaky when used with implicit remoting. People seem to be able to work around it by setting $ErrorActionPreference, instead of using the -ErrorAction parameter. (This is annoying, and I’d call it a bug in PowerShell, but that’s where things stand at the moment.)

Strange thing is it works just fine in every computer I have with PS version 4 (we use the same script in at least 6 different machines with Win7 or 2012), but on my laptop with PS version 5 and Win10 it won’t.