How to ignore an error in Powershell and let it continue?
Add -ErrorAction SilentlyContinue
to your command.
When it's not an error, but an unhandled Exception, you should add -EV Err -EA SilentlyContinue
, in order to catch the exception. (EA
is an alias for ErrorAction
)
You can then evaluate the error in your script, by having a look at $Err[0]
Short answer:
Add $ErrorActionPreference = 'SilentlyContinue'
at the start of your code so you don't need to add -ErrorAction SilentlyContinue
to every command
Long answer: https://www.gitbook.com/book/devopscollective/the-big-book-of-powershell-error-handling/details