Closed plastikfan closed 3 years ago
Raised an issue in PowerShell repo: Why is accessing Count property on Hashtable unreliable?
Actually, the best way going forward is to use PSBase to accesss a hashtable's properies in a reliable fashion. So:
$Hash.PSBase.Count
rather than
$Hash.Keys.Count
because even direct use of 'Keys' on Hashtable could fail, if the hashtable itself contains a key named 'Keys'.
It has been discovered that when dealing with hashtables, it is best not to use the Count property on the hashtable as it is unreliable and can sometimes cause the following error:
The better way to check this is to use the Count property on keys ie:
not