How to use PowerShell Try, Catch and the Write-Verbose and Write-Debug
A look at a few key constructs to help handle errors and troubleshooting in your PowerShell scripts.
My Files - https://github.com/johnthebrit/RandomStuff/blob/master/PowerShellStuff/HandlingErrors.ps1
https://github.com/johnthebrit/RandomStuff/blob/master/PowerShellStuff/OutputInfoFunc.ps1
Microsoft Document - https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-exceptions?view=powershell-7.1
00:00 Introduction
00:45 Error variable
02:22 Custom error variable
03:25 Try-Catch
05:01 ErrorAction
06:45 Error details
08:35 Error specific Catch
09:37 ErrorActionPreference
12:09 Errors from cmd.exe
13:25 Messages in scripts
15:09 Using CmdletBinding, Write-Verbose and Write-Debug
17:43 Summary and close