How to clear $Error in PowerShell?

Powershell

Powershell Problem Overview


Is there a way to clear the $Error variable that tracks errors in a PowerShell session?

If so, how do you do it?

I have tried: $error.clear

In the PowerShell ISE on Windows 7 and the $Error array is still populated.

Powershell Solutions


Solution 1 - Powershell

It is a .NET method call so you need parens:

$error.clear()

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatt SpradleyView Question on Stackoverflow
Solution 1 - PowershellKeith HillView Answer on Stackoverflow