title: Powershell to tally up departments in a file
body: <p>To be honest up front I really have no idea how to start this but here is what I am trying to accomplish.</p>
  
  <p>I have a csv file that has a list of usernames. What I am trying to do it perform a lookup of the username, get the department and as I parse through the csv tally up the number of times it is found.</p>
  
  <p>For example </p>
  
  <pre><code>Human resources 2
  information Technology 5
  </code></pre>
  
  <p>As previously stated I am not sure how to even approach this other than I know I will need to parse the departments first then go into the number count.</p>
  
  <pre><code> Import-Module ActiveDirectory
  
   Import-CSV "C:\Input.csv" | % {Get-ADUser $_.LoginID -Properties * | Select      -Property Department} | Export-CSV "C:\ADUsers.csv" -NoTypeInformation -Encoding UTF8   
  </code></pre>