We all have different way to accomplish a task that is given to us. Sometimes we make mistakes and we are panicking to fix the errors better know as PowerShell error handling.
Sometimes, knowing your mistakes is better than googling or trying to the answers. I’m comfortable with PowerShell, the errors are defined in a pretty straight forward way.
The errors come out as objects with properties too and this can come in handing when you want your script to show a specific error for a certain function.
So take some time and look at cmdlets write-error and also using the cmdlet binding parameters found on built in PowerShell commands “-ErrorAction” and combining them with try, catch, and finally statements that are the dream team when it comes with error handling.

There are a number of different option regarding this and what you need, is what you should choose. try them all on and see what shoe fits.

Newer Version of PowerShell has a great deal of newer functionality and choices.

Notice how the break command drops into a debug prompt instead. This helps with Scripting and finding… bugs. so now that we have squashed that the next thing is to find was to have it help you to avoid red letters and failed automation. Share what you have done with it.