Using PowerShell to copy Active Directory Group Membership

If you’ve ever needed to group membership between to AD groups you could do this one by one which while does work, what happens if you have a list with 10, 20, 30,….or even 5000+ users? To copy the membership from one group into another via PowerShell under Server 2008 is a simple two lines (plus import command).


Import-Module ActiveDirectory

$mymembers = Get-ADGroupMember -identity My_Source_Group_Name | Select-Object SamAccountName

foreach($i in $mymembers){Add-ADGroupMember -Identity My_Destination_Group_Name -Members $i.SamAccountName}

Join the Conversation


  1. Worked great for me! Any chance you can show how to add users from different child domains to the top level domain group. Your script fails if the username is not found in the same domain as the group created.

  2. If using child domains you can used the DistinguishedName attribute instead of SamAccountName. Depending upon your topology, you may need to wrap the Add-ADGroupMember method with some string matching against the end of the DistinguishedName.

Leave a comment

Your email address will not be published. Required fields are marked *