Single Command : Copy Users from one group to another


If you have a requirement to copy all the users from one group to another group then sometimes the one liner commands are amazing, this is one of those, this is the command.

Note : You need to use the samAccountName for the group and not the UPN in this example, this is also known as the Pre-Windows 2000 name:

Get-ADGroupMember -Identity "<SourceGroupName>" | ForEach-Object {Add-ADGroupMember -Identity "<DestinationGroupName>" -Members $_.SamAccountName}

This will then take the source group members and copy them to destination group, this was handy for a one time command where the situation required it.

Previous Post Next Post

نموذج الاتصال