← script library

Copy Group Memberships Between AD Users with PowerShell

Active DirectoryAugust 17, 2026

Copies every group membership from a reference user to a target user, which is how the request usually arrives: give the new starter the same access as their colleague. Short enough to audit at a glance before you run it, which matters for a script that hands out access.

powershell
# Active Directory: Clone all groups from a reference user to another
#-------------------------------------------------

Import-Module ActiveDirectory

$sourceUser = "{sourceUser}" # sAMAccountName
$targetUser = "{targetUser}" # sAMAccountName

Get-ADUser -Identity $sourceUser -Properties MemberOf |
Select-Object -ExpandProperty MemberOf |
ForEach-Object {
	Add-ADGroupMember -Identity $_ -Members $targetUser
}
Write-Host "$targetUser now has the same group memberships as $sourceUser."

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.