Errors

Errors: Reading Errors, and `-ErrorAction`, `try`, `catch` and `finally`.

Updated

  1. Reading Errors, and `-ErrorAction` (Apprentice): PowerShell's red text names the command that failed, what went wrong and, in a script, the file and line; some errors stop a command and some let it carry on, -ErrorAction decides what happens next, and $Error keeps a list of them.
  2. `try`, `catch` and `finally` (Journeyman): try runs your lines, catch runs only if one of them hits an error that stops it (which -ErrorAction Stop arranges), $_ in catch is the error, so you can tell the user what happened and what to do, and finally runs whatever happens.