error
suggest changeArray of most recent error objects. The first one in the array is the most recent one:
PS C:\> throw "Error" # resulting output will be in red font
Error
At line:1 char:1
+ throw "Error"
+ ~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Error:String) [], RuntimeException
+ FullyQualifiedErrorId : Error
PS C:\> $error[0] # resulting output will be normal string (not red )
Error
At line:1 char:1
+ throw "Error"
+ ~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Error:String) [], RuntimeException
+ FullyQualifiedErrorId : Error
When you pass $Error to a Format-* cmdlet such as Format-List, add -Force. Otherwise the formatter uses $Error's default view, which looks like the error text above.
Error entries can be removed via e.g. $Error.Remove($Error[0]).
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents