by southtx07 at 2013-02-22 14:54:28
If anyone can give me advice on my script I’d greatly appreciate it. What I currently have I can copy group memberships from one account to another, but how do I modify to do a bulk copy? There has to be an easier way than listing out all the users (i.e -identity "user1", "user2", etc.). The user accounts are in a text file and there 200+ accounts. thanksby kittH at 2013-02-22 15:37:59
$OldUser = Get-QADUser -Identity ‘user1’
$NewUser = Get-QADUser -Identity ‘user1_adm’
$users = Get-QADUser $OldUser |select memberof
foreach($user in $users.memberof)
{
Add-QADGroupMember -Identity $user -Member $NewUser
}
You can use Get-Content to read the text file, and then a foreach loop to perform your action… This is untested but should be pretty close:$OldUser = Get-QADUser -Identity 'user1'
$NewUsers= Get-Content C:\Users.txt
$Groups = Get-QADUser $OldUser | Select -ExpandProperty MemberOf
Foreach($NewUser in $NewUsers)
{
foreach($Group in $Groups)
{
Add-QADGroupMember -Identity $Group -Member $NewUser -WhatIf
}
}