How to clear $ Error in PowerShell?

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

If so, how do you do it?

I tried: $error.clear

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

+43
powershell
Nov 11 '09 at 17:13
source share
2 answers

This is a .NET method call, so you need parens:

 $error.clear() 
+71
Nov 11 '09 at 17:42
source share

$True usually evaluated as true. I do not know if you can set it as false. I think you could, if only it were not read-only. Of course, it is not recommended to install it on something else. System-independent translations probably exist as if (1), but I would not guarantee this.

 if($True) {write-host "Foo!"} 

then you can execute

 if($False) {write-host "not"} 
-13
Nov 27 '09 at 6:46
source share



All Articles