Yesterday i needed to copy a lot of users from one Active Directory group to another one, of cause this should be done via PowerShell!

The script i created was fairly simple, there is no error handling, so you might see an warning, if a user is already member of the target group.

I wanted to share the script with you, so here it is

Copy users from one AD group to another using PowerShell

# Enter the name of the group you want to copy from
$SourceGroup = 'My Source Group Name'

# Enter the name of the group you want to copy to (it must already exist)
$TargetGroup = 'My Target Group Name'

# Importing the Active Directory PowerShell Module
Import-Module -Name ActiveDirectory

# Loading all the group members into a variable, that we can loop
$GroupMembers = Get-ADGroupMember -Identity $SourceGroup
# Loop through the variable of members, to add them to the new group
Foreach ($GroupMember in $GroupMembers)
  Add-ADGroupMember -Identity $TargetGroup -Members $GroupMember -Verbose

I have choose to add the -Verbose to the “Add-ADGroupMember” function, because i wanted to get status by every line. You can feel free to remove that.

As a last note: Use the on your own risk!