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.
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.
Does PowerShell have a command you can run which always succeeds, thus clearing $Error? (true
on *nix is one such program, to compare.)
$True
thats usually true. I dont know if you can set it to be false. I guess you might unless it's readonly. Ofc wouldnt recommend setting it to something else. Probably system-independent translations exist like if(1), but I wouldn't guarantee that.
if($True) {write-host "Foo!"}
then you can execute
if($False) {write-host "not"}