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:  

Advertisements

One thought on “Copy Group Membership From One User To Another

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s