AntiMalware Status

Copy Group Members from One group to Another

Simple PowerShell script to move members of one group to be also members of new group that you have just created.
I am using this very often. It is time saver to move large number of users between groups.

1
2
3
4
5
6
7
Import-Module ActiveDirectory
$gsource = "GroupA"
$gtarget = "GroupB"
Get-ADGroupMember -Identity $gsource |
foreach {
Add-ADGroupMember -Identity $gtarget -Members $($_.DistinguishedName)
}

Because I am using the distinguished name property from the group member object to define the user, this will throw an error message if the user already exists in the group but will continue. This apply if you are copying members from existing group to existing group and there is a chance that some users are already members of both groups.

Leave a Reply