# Powershell 5 ErrorAction Stop

**URL:** <https://forums.powershell.org/t/powershell-5-erroraction-stop/4773>\
**Category:** PowerShell Help\
**Created:** [August 27, 2015, 10:28pm UTC](https://forums.powershell.org/t/powershell-5-erroraction-stop/4773 "2015-08-27T22:28:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![valentin-pechersky](https://avatars.discourse-cdn.com/v4/letter/v/4af34b/32.png) [@valentin-pechersky](https://forums.powershell.org/u/valentin-pechersky)\
**Post date:** [August 27, 2015, 10:28pm UTC](https://forums.powershell.org/t/powershell-5-erroraction-stop/4773/1 "2015-08-27T22:28:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [August 28, 2015, 12:32am UTC](https://forums.powershell.org/t/powershell-5-erroraction-stop/4773/2 "2015-08-28T00:32:33Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![valentin-pechersky](https://avatars.discourse-cdn.com/v4/letter/v/4af34b/32.png) [@valentin-pechersky](https://forums.powershell.org/u/valentin-pechersky)\
**Post date:** [August 28, 2015, 5:44am UTC](https://forums.powershell.org/t/powershell-5-erroraction-stop/4773/3 "2015-08-28T05:44:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:44pm UTC](https://forums.powershell.org/t/powershell-5-erroraction-stop/4773/4 "2024-05-16T20:44:51Z")

</div>


