Sune
Sune

Reputation: 3270

How to properly count elements in my object collection

I have the following collection;

Collection  Property1   Property2
---------------------------------
Coll1       blue        hot
Coll1       red         cold
Coll1       yellow      orange
Coll1       false       false
Coll2       dog         cat
Coll2       out         in
Coll2       house       car
Coll3       yellow      red
Coll3       brick       mortar
Coll3       winter      winter
Coll3       summer      summer
Coll3       ski         snow
Coll3       cyan        brown

How do I count how many elements that are in Coll1 (the number of collections will be dynamic so the filter also has to be)? I guess I am looking for something like how many elements has a unique collection ID

Upvotes: 2

Views: 811

Answers (1)

Joey
Joey

Reputation: 354356

I haven't seen a hashtable in PowerShell that would output as what you have shown in your question, but usually the way is like the following:

Get-Foo | Group-Object Collection -NoElement

Upvotes: 3

Related Questions