We all know that we can have multiple catch blocks when using a try/catch/finally, right?
When using try/catch/finally with PowerShell, don’t forget that when an error occurs, the jump to the catch fires, and the first matching catch block will be executed so getting the order of your catch blocks correct is important.
You need to ensure that the catch blocks are ordered from “specific” to “generic”. Look for specific errors first, less specific next, and so on all the way to your most generic.
more to follow…