When you handle errors yourself using Trap or try/catch, you should make sure that you set your ErrorActionPreference to “Stop” or specify -ErrorAction Stop for each cmdlet you want to handle. Otherwise, Cmdlet exceptions would be invisible to your error handlers and handled by PowerShell automatically.