MicroNuggets: PowerShell Error Handling Explained

Описание к видео MicroNuggets: PowerShell Error Handling Explained

Start learning cybersecurity with CBT Nuggets. https://courses.cbt.gg/security

In this video, Don Jones covers error handling in PowerShell. Something that sets a good script apart from a truly great one is its ability to respond to errors that you anticipated ahead of time. Watch as Don demonstrates the fine art of error handling.

Everyone knows that the single most aggravating thing that can go wrong while coding is an innocuous semicolon wreaking havoc on your otherwise pristine code. But coming in at a very close second is an unanticipated error in execution that causes PowerShell to explode.

Preventing and handling errors takes foresight and planning, see some of the more common approaches to anticipating potential errors and catching them.

The trick is diagnosing your code once it's complete — find the lines of code that are actually doing something and consider whether they could return an error. This could be something like a computer not being available when we query it, or not having permission to query it.

Wrapping commands like that in Try/Catch block can provide outlets for errors, and you can also catch the error in an error variable. Don introduces you to these and many more diagnostic approaches and error handling solutions you'll need.

📁 Download the Ultimate Sysadmin Cert Guide: https://blog.cbt.gg/dyvk

⬇️ 4-Week Study Plan: MD-100 & MD-101: https://blog.cbt.gg/9dlw


Start learning with CBT Nuggets:

• PowerShell | https://courses.cbt.gg/be3

Комментарии

Информация по комментариям в разработке