How add all users from one group to another group

biplabmukherjee
biplabmukherjee used Ask the Experts™
on
Hi all,

Can you guys please guide me to how can I add all users from one group to another group. I am giving you an example. Just like domain users its containing 2000 usres. I want to create a duplicate copy of domain users. like TempDomainUsers. I dont want to move. I want to add all users from domain Users to  TempDomainUsers for testing web sense. Do I need to run the script , If needed help me to create the script or how will I move 2000 users at a time. Please help me out as early as possible.

Thanks & Regards,

Biplab
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
remmett70Network Manager

Commented:
Wouldn't nesting the Domain Users group as a member of this new group accomplish what you are looking for?

Author

Commented:
I want to add all users from  domain users group to be a member of TempdomainUsers group. I dont want to move all users from one group to another group I just want to add same users . Just a duplicate copy of Domain Users . I thik its might clear your dobut.

Repeating one again .  Want to add all users from domain users group to newly created group namely " TempdomainUsers" . How can I do this?
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
Try the script below; I can't test it at the moment, so try it with two test groups with only a few members first.
You obviously have to replace the two DNs at the beginning with the correct group DNs.

@echo off
set SourceGroupDN=cn=SomeGroupName,ou=SomeOU,dc=domain,dc=local
set TargetGroupDN=cn=SomeOtherGroupName,ou=SomeOU,dc=domain,dc=local
dsget group "%SourceGroupDN%" -members | dsmod group "%TargetGroupDN%" -addmbr

Open in new window

Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
@echo off
set SourceGroupDN=cn=domain users,ou=users,dc=interhealth,dc=org
set TargetGroupDN=cn=tempdomainusers,ou=users,dc=interhealth,dc=org
dsget group "%SourceGroupDN%" -members | dsmod group "%TargetGroupDN%" -addmbr

Can you please check out the syntax what I have entered its correct or not. while running i got Invalid character. Can you plz check
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
The default "Users" in AD is not a OU, it's actually a container.
@echo off
set SourceGroupDN=cn=domain users,cn=users,dc=interhealth,dc=org
set TargetGroupDN=cn=tempdomainusers,cn=users,dc=interhealth,dc=org
dsget group "%SourceGroupDN%" -members | dsmod group "%TargetGroupDN%" -addmbr

Open in new window

Author

Commented:
run it but its added only on user from existing group to newly created group. like domain users to tempdomainusers.
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
Sorry, forgot, that won't work with the Domain Users group.
If you want to have all domain users in the TempDomainUsers group, use the following:
@echo off
set TargetGroupDN=cn=tempdomainusers,cn=users,dc=interhealth,dc=org
dsquery user -limit 0 | dsmod group "%TargetGroupDN%" -addmbr

Open in new window

Author

Commented:
Just have quick question. before i run this I dont want to move I want to add. after applying this command all users will be a member of domain users as well as tempdomin users right?

Author

Commented:
Run this script but nothing is moved too new group from exsting ones :)

Author

Commented:
Any update?
remmett70Network Manager

Commented:
The script may have a problem because of the number of users.  You stated over 2000.

Here is another topic,

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24084873.html

Author

Commented:
this link is different the matter which I m talking about. Yes agreed that I stated to move 2000 users & the link which u have sent is discussing form of ADSI bug why its unable to move more than 1500 users in one instance & the script deal with SAMAccountname . I want to know the script to add the users from one group to another group. Nothing else.
remmett70Network Manager

Commented:
The first line of oBda script looks like it needs a set of Quotes around the DN of the object.  Replace that line with this

set TargetGroupDN="cn=tempdomainusers,cn=users,dc=interhealth,dc=org"

See if that helps
remmett70Network Manager

Commented:
Sorry cut from the wrong code bit.

set SourceGroupDN="cn=domain users,cn=users,dc=interhealth,dc=org"

Author

Commented:
Tried dint work . Hopeless :)
remmett70Network Manager

Commented:
Give this one a try from a command prompt.

dsquery group domainroot -name "domain users" | dsget group -members
| dsmod group cn=tempdomainusers,cn=users,dc=interhealth,dc=org -addmbr

Author

Commented:
tried not working not adding single users onto the new group. ( Temdomainusers)
remmett70Network Manager

Commented:
Well it looks like there is not easy way to accomplish this.  The scripts would work fine with any group other than the domain users group.

Can I ask again, why you need another group that contains all users for this testing?  Why not just use the domain users group?

Author

Commented:
Actually we are using Websense. so dont want to messed up with the domain users. trying 2 create a duplicate copy of domian users will add the newly created group to websense console & enable the policy.

Is there any way we can accomplish this?

remmett70Network Manager

Commented:
By default each user is a member of the domain users group, unless somebody has gone in and removed them from the group you should be able to do this through the Users and Computers.

Just go to the group properties > Members tab  select add

In the selection window click the Object Types button and remove Other Objects and Groups so only Users are selected.  Make sure the root of the domain is selected in the from location.

Select Advanced, then Find Now.  This should list every user in the domain.
select the first name, then shift+end to select every account and hit OK

That will put every account in the domain into that group.  If you have removed certain users from the domain users group, then I don't know if I have an idea for you.

Author

Commented:
I did as you said able to add all members into the new group but once I click " Apply " or "Ok" button error message is poping up saything this " The following Active directory error occured- Directory service is busy".

Any Idea?
Network Manager
Commented:
Guess off hand is that there are to many objects being added to the group.

Only suggestion is to do it in chuncks.  Try selecting the first user and adding by itself to make sure that goes.  If OK, then grab the second user and shift+Page Down for about 1/2 the alphabet about M or so and see if you can add that chunk.  If successfull then add the rest of the alphabet.

Author

Commented:
Thanks at last I was able to move all users. Thank You guys for helping me.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial