For-Each aggregation on a single HashtBable returns an array of HashTable[]

Viewed 42

I'd like to scan the src/ directory for all .pdb files but deduplicate them by their names (since a file of the same name might appear multiple times in various subdirectories). I thought something like this would do it.

$x = ls .\src\ -Recurse -Include *.pdb | 
     % { $a[$_.Name] = $_; $a } -Begin { $a = @{} }

And it sort of does but surprisingly $x.GetType() is Object[] not Hashtable. Instead, each of the items in the Object[] array seems to be a Hashtable.

I really don't understand why this is happening, it seems like $x should be a Hashtable

2 Answers
Related