Copy Group Membership From One User To Another

I couldn’t find an easy quick way to do this so I took an old powershell script I found and modified it to work in Windows 2008 R2 and later environments.

   1: import-module ActiveDirectory
   2: cls 
   3: write-output "This script adds the destination user to all the Groups which the source user is memberof." 
   4: write-output " " 
   5: write-output " " 
   6: $SName = Read-Host "Please Enter the alias name of the source user " 
   7: $DName = Read-Host "Please Enter the alias name of the Destination user " 
   8:  
   9: $K = Get-ADUser -Identity $SName -Properties memberOf
  10: foreach($group in $K.memberof)  
  11: {  
  12: Add-ADGroupMember -Identity $group -Member $DName 
  13: write-output $group 
  14: }  
  15: