← 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.
More in Active Directory
Active Directory User Onboarding with PowerShell
2026-08-17Active Directory User Offboarding with PowerShell
2026-08-17Disable an Active Directory User with PowerShell
2026-08-17Enable an Active Directory User with PowerShell
2026-08-17Unlock an Active Directory Account with PowerShell
2026-08-17Reset an Active Directory Password with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.