title: Add multiple users to multiple groups from one import csv (follow up query)
body: <p>I was looking for a way to populate multiple distribution groups with multiple user names. I came across <a href="https://stackoverflow.com/questions/16651580/add-multiple-users-to-multiple-groups-from-one-import-csv#new-answer?newreg=49d4e98054ae4ec7aa6761c0aa7d354e">a script on this site written by member Frode F.</a>:</p>
  
  <pre><code>Import-Csv "C:\Scripts\Import Bulk Users into bulk groups\bulkgroups3.csv" | Group-Object Group | % {
      #Foreach Group, get ADUser object for users and add members
      $users = $_.Group | % { Get-ADUser $_.Accountname }
      Add-ADGroupMember -Identity $_.Name -Member $users
  }
  </code></pre>
  
  <p>This was working when the csv file contained about 10 lines with 2 different groups in column 1 and multiple users in column 2.
  When the csv contains a few hundred lines, still only 2 groups it fails to populate the groups at all. These are the errors:</p>
  
  <pre><code>Add-ADGroupMember : The specified account name is already a member of the group
  At C:\scripts\AddUsersDistributionGroups.ps1:6 char:22
  +     Add-ADGroupMember &lt;&lt;&lt;&lt;  -Identity $_.Name -Member $users
      + CategoryInfo          : NotSpecified: (Group A:ADGroup) [Add-ADGroupMember], ADException
      + FullyQualifiedErrorId : The specified account name is already a member of the group,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember
  
  Add-ADGroupMember : The specified account name is already a member of the group
  At C:\scripts\AddUsersDistributionGroups.ps1:6 char:22
  +     Add-ADGroupMember &lt;&lt;&lt;&lt;  -Identity $_.Name -Member $users
      + CategoryInfo          : NotSpecified: (Group B:ADGroup) [Add-ADGroupMember], ADException
      + FullyQualifiedErrorId : The specified account name is already a member of the group,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember
  </code></pre>
  
  <p>Can anyone help?</p>