Lets say I ran a command with ErrorAction Stop and it generated an error. I would like to know whether the error was originally terminating or not? I have the ErrorVariable or $Error object. Does ErrorVariable catches both kind of errors? I am looking for a property in .NET/PowerShell object which could tell me that this Error was terminating. Are exceptions generated for Non-Terminating errors too?
Plus, when I am writing a command on console (not ISE and not running a script, just single command on console), how can I suppress the Error using ErrorAction variable? Basically, there should not be any red output on the screen.
about_Try_Catch_Finallyandabout_Traphave some helpful information.By default non terminating errors aren't caught by try catch but they will show up in
$error. You can use-ErrorVariableto define another error variable (about_CommongParameter. So you could use a custom variable for a check for non terminating errors which might make your code easier readable.By using
SilentlyContinuethe output is suppressed but the error is still recorded in the error variable.