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.

Leave a comment

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

  • Profiting by gaining everything!

    What does “having it all” mean to you? Is it attainable? What does it mean to have it all? To me, it means that we’re thinking about the projects that…

    ·

  • Leader in Following

    Are you a leader or a follower? I want you to read into this without reading too deeply. I believe good leaders are followers. So for most things in this…

    ·

  • Faded memories and logos

    What’s the oldest things you’re wearing today? So the oldest thing that I’m wearing today is actually my Samsung jacket, and it reminds me a lot of where I’ve come…

    ·

Spam-free subscription, we guarantee. This is just a friendly ping when new content is out.

Go back

Your message has been sent

Warning
Warning
Warning.