Avatar of Joseph Moody
Joseph Moody
Flag 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
PowershellVB ScriptActive Directory

Avatar of undefined
Last Comment
Joseph Moody

8/22/2022 - Mon
George Khairallah

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
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

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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Joseph Moody

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Joseph Moody

ASKER
The script accomplishes my goal! Sharing for others to see.