Given a list with some duplicate items, I can use Group-Object -AsHashtable
and I get a hash table that seems to have keys with the item names, and the value is something I don't recognize.
So, given
$array = [System.Collections.Generic.List[String]]@('A', 'B', 'C', 'B', "c", 'C')
$grouped = $array | Group-Object -AsHashTable
$grouped
will be
Name Value
---- -----
A {A}
B {B, B}
C {C, c, C}
At which point I would have thought that $grouped['B'].Count
or $grouped.'B'.Count
would produce the correct count of 2. But I am getting 0. What am I missing?
CodePudding user response:
You're seeing a bug in Windows PowerShell that has since been fixed in PowerShell (Core) 7 - see