Category Archives: Powershell

Copy group memberships from one active directory group to another using Powershell

A quick way to copy group memberships from one AD group to another.

A loop is required as Add-ADPrincipalGroupMembership will fail and error out if one the users of the first group is already a member of the second group. The loop ignores these errors and allows the command to continue.

$ErrorActionPreference = "SilentlyContinue"
 Get-ADGroupMember -Identity "Group1" | % { $_ | Add-ADPrincipalGroupMembership -MemberOf "Group2" }
 $ErrorActionPreference = "Continue"