Link to home
Create AccountLog in
Avatar of Joseph Moody
Joseph MoodyFlag for United States of America

asked on

Move Security Group Members to Another Group

I have a security group with a lot of nested groups. I have another security group with the same number of tested groups. How can I take the members of the nested groups and move them to the new security group.

Ex:

SG_1
       London_SG_1
       Paris_SG_1

Move members of London and Paris corresponding group:

SG_2
       London_SG_2
       Paris_SG_2
Avatar of George Khairallah
George Khairallah
Flag of United States of America image

Are you looking to do this in a scripted basis? or just a one time thing. Would something like this work ?  (it's quick'n'dirty, but if it's one time, then it shouldn't be a problem)

dsquery group -name "groupname" "ou=ouname,dc=example,dc=.com" |dsget group -members |dsget user -samid

Open in new window


Or something like this may also be useful to you:
http://adisfun.blogspot.com/2009/06/find-group-members.html
Avatar of X Layer
You can try to achieve this with powershell. This is not tested script, try it and report back:
Import-Module ActiveDirectory
Get-ADGroupMember -Identity London_SG_1 | foreach { Set-ADGroup -Identity London_SG_2 }
Get-ADGroupMember -Identity Paris_SG_1 | foreach { Set-ADGroup -Identity Paris_SG_2 }

Open in new window

Avatar of Joseph Moody

ASKER

Thank you both for the replies! This could be a regular occurrence as we try to simplify our group structure.

I modified the second script a little bit to use the quest AD cmdlets. If the script is this:

get-qadgroupmember -identity "SD_Test Group 1" -indirect -type computer | Add-QADGroupMember -identity "SD_Test Group 2"

It will get all of the nested computers from SD_TEST Group 1 but put them in the root of SD_TEST Group 2.

If I add in the foreach statement, I am prompted to type in the computer names.
ASKER CERTIFIED SOLUTION
Avatar of Joseph Moody
Joseph Moody
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
The script accomplishes my goal! Sharing for others to see.