Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Create a distribution group in the root Domain and add users. I have the group names and user names in 2 diffetent txt files. Any way of doing this.

Hi,

Create a distribution group in the root Domain and add users. I have the group names and user names in 2 diffetent txt files. Any way of doing this.

A script that checkes the "Group.txt" and creates the group and add's the user names that are in the "Users.txt" file

I need to create 40 groups with the similar 100+ users.

Any help....

Reards
Sharath
Avatar of lcoady
lcoady
Flag of United States of America image

can you give example input from both files and the desired result in terms of group and user creation?
Avatar of bsharath

ASKER

2 txt files

Groups.txt
Users.txt

When script run has to check the "Groups.txt" create the groups. Should have an option for Universal \ Distribution or Global \Security and add all users  in the txt to the group.

If i have 10 group names and run the script create 10 groups and add all users to the 10 groups.

Results file that can show success/failure too..
2 txt files

Groups.txt
Users.txt

When script run has to check the "Groups.txt" create the groups. Should have an option for Universal \ Distribution or Global \Security and add all users  in the txt to the group.

If i have 10 group names and run the script create 10 groups and add all users to the 10 groups.

Results file that can show success/failure too..
Avatar of RobSampson
Sharath, there's code to create four types of group definitions described here:
http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/usersgroups/groups/

Domain Local Distribution
Global Security
Universal Distribution
Universal Security

I'm thinking, in your Groups.txt, if you have

GroupA|Global Security
GroupB|Universal Security

etc, where the group name is separated by a pipe character to the type, we can create the group correctly.....are you able to do that?

Regards,

Rob.
Can the group type be mentioned in the script Rob...
So i can have 4 diffirent scripts to do this...
Can the group type be mentioned in the script Rob...
So i can have 4 diffirent scripts to do this...
Oh, yeah, that's the other option.....you can have one script for each group type......

What if we make just one script, with a message box that says

What group type are you creating from <groups.txt>?
1) Domain Local Distribution
2) Global Security
3) Universal Distribution
4) Universal Security


and you can select a number, then it will create that group type?

Rob.
Yes that would be even better...
Yes that would be even better...
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank Rob where will the group get created. Can i mention the local OU or Root OU path in the script.
Thank Rob where will the group get created. Can i mention the local OU or Root OU path in the script.
On this line:
strOU = "CN=Users," & strDomain

and also, when you run it, you will see where the groups will be created in the message box.

Regards,

Rob.
Rob it works great when want to create the group in local Domain.

When i enter the OU path as the Root Domain. Just the OU name. I get an error as cannot find the OU...

Is there any thing we need to change  for root domain.
Rob it works great when want to create the group in local Domain.

When i enter the OU path as the Root Domain. Just the OU name. I get an error as cannot find the OU...

Is there any thing we need to change  for root domain.
Try changing this:
strOU = "CN=Users," & strDomain

to something like
strOU = "rootDC1/CN=Users,DC=root,DC=domain,DC=com"

Regards,

Rob.
Rob i think the script by default takes the Domain Name. Now when i change the data as above it even gets the Domain name at the end of this

strOU = "rootDC1/CN=Users,DC=root,DC=domain,DC=com"
Rob i think the script by default takes the Domain Name. Now when i change the data as above it even gets the Domain name at the end of this

strOU = "rootDC1/CN=Users,DC=root,DC=domain,DC=com"
Rob i commented  this
'& strDomain

I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Create groups & add Users.vbs
Line:      26
Char:      1
Error:      There is no such object on the server.
Code:      80072030
Source:       (null)

---------------------------
OK  
---------------------------
Rob i commented  this
'& strDomain

I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Create groups & add Users.vbs
Line:      26
Char:      1
Error:      There is no such object on the server.
Code:      80072030
Source:       (null)

---------------------------
OK  
---------------------------
Try
strOU = "CN=Users,DC=root,DC=domain,DC=com"

without the DC name....it may work....

Rob.
I tried Rob but did not work

strOU = "CN=All Groups ,DC=root,DC=domain,DC=com"
Is there a problem with a space in the OU name...
I tried Rob but did not work

strOU = "CN=All Groups ,DC=root,DC=domain,DC=com"
Is there a problem with a space in the OU name...
I tested Rob it created a group on the root Domain but not in an OU with spaces...
I tested Rob it created a group on the root Domain but not in an OU with spaces...
Yes, if the group name does not have the space, that will not work....
If the OU name has spaces? it does not create.
Oh, with
strOU = "CN=All Groups,DC=root,DC=domain,DC=com"

that first CN= only works for inbuilt containers, for custom OU's, you need OU instead of CN

strOU = "OU=All Groups,DC=root,DC=domain,DC=com"

Regards,

Rob.