This article will guide you on how to tackle PowerShell $Error clear and method to clear errors with $Error.
To clear error variable when you start #PowerShell, simply run $error. clear(). A downside of this method is that you lose all the errors that were generated before you clear the error variable.
To delete a variable, along with its value, use Remove-Variable or Remove-Item. This cmdlet does not delete the values of variables that are set as constants or owned by the #system, even if you use the Force parameter.
1. You can use this variable to represent an absent or undefined value in #commands and #scripts.
2. #Windows PowerShell treats $null as an object with a value, that is, as an explicit placeholder, so you can use $null to represent an empty value in a series of values.