As you write PowerShell scripts, it is important that you include error handling. Most of the time, this involves the use of Try/Catch statements. The tricky thing with Try/Catch is that you can only catch a terminating exception. There are a few cmdlets that by design will throw a terminating exception. But you have no...
Check out my PowerShell Essentials page https://jdhitsolutions.com/blog/essential-powershell-resources/