Understand the Error of your ways.

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.

5.1 options

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

Powershell 7.2

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.

Published by Xajuan Smith

Computer Information Specialist, with a desire to make the masses feel what I was born to channel...The emotion that strives us to do more, speak more boldly and with most sincere ideals that will make life easier and will not hinder the dreams we all have at any given time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: