Powershell to Copy Group Members from One User to Another


posted by Krishna
01-19-2010

Downloads: 590
File size: 621 B
Views: 4,982

Embed
Powershell to Copy Group Members from One User to Another
  1. Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin 
  2. Add-PSSnapin Quest.ActiveRoles.ADManagement 
  3. cls 
  4. write-output "This script helps to add user to all the Groups which other user is memberof.It is can be normally used when new user needs to have all the group membership of the existing users" 
  5. write-output " " 
  6. write-output " " 
  7. $SName = Read-Host "Please Enter the alias name of the source user " 
  8. $DName = Read-Host "Please Enter the alias name of the Destination user " 
  9.  
  10. $K = Get-QADUser $SName |select memberof  
  11. foreach($user in $K.memberof)  
  12. {  
  13. Add-QADGroupMember -Identity $user -Member $DName 

Comments

focuswrckrakow wrote re: Powershell to Copy Group Members from One User to Another
on 02-15-2011 12:11 PM

Krishna,

This is a great script.  I am new to powershell.  Do you happen to know how I could change this script to work exactly the same way for computers instead for users?

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.