Powershell catch non-terminating errors WITH SilentlyContinue


I would like to catch and handle non-terminating errors but using -ErrorAction SilentlyContiune. I know I need to use -ErrorAction Stop in order to catch a non-terminating error. The problem with that method is that I don’t want my code in the try script block to actually stop. I want it to continue but handle the non-terminating errors. I would also like for it to be silent. Is this possible? Maybe I’m going about this the wrong way.

An example of a nonterminating error I would like to handle would be a access denied error to keyword folders from Get-Childitem. Here is a sample.


You cannot use Try/Catch with ErrorAction SilentlyContinue. If you want to silently handle the errors, use Stop for your ErrorAction, and then use the Continue keyword in your Catch block, which will make it continue the loop with the next input object:


Powershell catch non-terminating errors WITH SilentlyContinue by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply