title: How to get Count of Values from a Hashtable per key in powershell
body: <p>Currently I am able to get the list of values from a hashtable with the below cmdlet, but I would like get a count of values per key. Please lend me some advice, if this can be achieved using GetEnumerator method</p>
  
  <pre><code>$keys.GetEnumerator() | % {
      [PSCustomObject]@{
          key = $_.Value
      }
  }
  </code></pre>
  
  <p>My Hashtable $keys:</p>
  
  <pre><code>Name                           Value                                                                                                 
  ----                           -----  
  9                              {G637A146}                                                                 
  -3                             {F637A146, G637A146}                            
  3                              {F637A146, E637A146}                            
  -2                             {F637A146} 
  </code></pre>
  
  <p>Expected Output Using GetEnumerator:</p>
  
  <pre><code>Key     Value                                                                                                 
  ----    ----- 
  9       1
  -3      2
  3       2
  -2      1
  </code></pre>
  
  <hr>
  
  <p>New Edit:
  2. How to get the unique count of values as well?
  My Hashtable $keys:</p>
  
  <pre><code>Name                           Value                                                                                                 
  ----                           -----  
  9                              {G637A146, F637A146, J637A146}                                                                 
  -3                             {F637A146, F637A146, G637A146, F637A146}
  </code></pre>
  
  <p>Expected Output Using GetEnumerator:</p>
  
  <pre><code>Key     Value                                                                                                 
  ----    ----- 
  9       3
  -3      2
  </code></pre>