What is an error?
As we’ve seen repeatedly, PowerShell, as with most languages, has its own terminology and definitions for common words. Error is no exception (except… sometimes it is, as we’ll see. That is an extremely funny joke. You’ll laugh later, I promise.). An error in PowerShell is, broadly, anything that might produce red text in the console. Let’s look at an example. In the console, type the following:
Get-ChildItem -Name nosuchfile
We will see a red message saying Get-ChildItem: cannot find path because it does
not exist
.
PowerShell is an extremely friendly and helpful language. It will always try to recover from an error and continue with what it was asked to do. In the preceding instance, it was asked to do one thing, couldn’t do it, and delivered a helpful error message written in plain language describing why it was unable to do the thing we asked for.
There is a lot of work going on in the background here. The previous...