Book Image

PowerShell Troubleshooting Guide

By : Mike Shepard
Book Image

PowerShell Troubleshooting Guide

By: Mike Shepard

Overview of this book

Table of Contents (15 chapters)
PowerShell Troubleshooting Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Reading error messages


This section shouldn't be necessary for people who are serious about writing scripts, but in my experience it involves one of the simplest techniques of troubleshooting and, unfortunately, one of the techniques that is often overlooked. We have talked about how to handle errors using try / catch / finally, and about the difference between terminating and non-terminating errors, but we haven't spent any time talking about error messages themselves. The simple practice of carefully reading the error messages that occur can help to pinpoint not only the problem, but also where the problem occurred in the code. While that information isn't unique to error messages in PowerShell, I have seen countless occasions where it is overlooked.

The color problem

My personal opinion is that the default color scheme in the console and the ISE is part of the reason. Due to the default color scheme, errors in PowerShell look somewhat jarring and cause me, at least, to try to skip over...