Active Directory – Copy users from one group to another


We are migrating our File Servers to Sharepoint Sites and one of the tasks is to review users’ permissions. We used to use Active Directory Groups to provide users access to File Shares but as part of the migrating process, we have to create new groups with a new naming convention instead of renaming the existing groups.

So I have used a simple Powershell script to do this.

So let’s suppose we have those two groups and want to copy the users from the left (FS_Group_Origin) to the right (Sharepoint_Group_Destiny).

First just to check I can run this Powershell script to list the users from the source group.

Get-ADGroupMember -Identity "FS_Group_Origin" | Select-Object Name | Sort-Object Name

Alright now we only need to pipe this result into another command:

Get-ADGroupMember -Identity "FS_Group_Origin" | ForEach-Object {Add-ADGroupMember -Identity "Sharepoint_Group_Destiny" -Members $_.distinguishedName}

Now both groups have the same users.

The downside of this method is that we have to create the destination group first, it works if you have a few groups but in a scenario where you have to do it for hundreds or thousands, it requests a lot of manual effort.

So my next post is going to solve this by creating the groups and copying the users all in a single script.

Thanks.


Leave a Reply

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