40 pts.
 Batch file to create users and groups
How do I create a set of scripts that can use any text file to create new groups and users and assign the users to the correct groups? Full names and user names must be set for the users. Also, where could I find a good reference site for commands that I may use to create batch files of my own? I'm using Windows XP and I'm not a skilled batch file maker yet. I don't know where to get started or implement it. Thank you very much.

Software/Hardware used:
ASKED: December 4, 2008  5:38 PM
UPDATED: May 7, 2013  6:58 PM

Answer Wiki:
Are you using Active Directory? If so, DSADD is the right tool. See these threads. Create an Excel spreadsheet with 2 tabs. One tab (UserInformation) is populated with the following column names in ROW1 (the values by each are the formulas in row 2 - if not a data string value):
A- SAM Name
B- FirstName
C- LastName
D- Description
E- Password
F- UPN = =A2&"@xx.company.com"
G- Display = =B2&" "&C2
H- Office
I- Email = =B2&"."&C2&"@xx.company.com"
J- MustChangePwd = yes/no
K- Disabled = yes/no
L- LoginScript = login.bat
M- cn= =A2
N- ou= =users
O- ou= =newOU
P- dc= =xx
Q- dc= =company
R- dc= =com
S- -samid =A2
T- -upn =CONCATENATE(AE2&F2&AE2)
U- -fn =CONCATENATE(AE2&B2&AE2)
V- -ln =CONCATENATE(AE2&C2&AE2)
W- -desc =CONCATENATE(AE2&D2&AE2)
X- -display =CONCATENATE(AE2&B2&" "&C2&AE2)
Y- -pwd =E2
Z- -office =H2
AA- -email =CONCATENATE(AE2&I2&AE2)
AB- -loscr =L2
AC- -mustchpwd =J2
AD- -disabled =K2
AE- "
Create as many rows as necessary in this for each of the users. A second tab would be named DSadduserTemplate and the contents of row 2 and below would be:
="dsadd user cn="&UserInformation!M2&",ou="&UserInformation!N2&",ou="&UserInformation!O2&",dc="&UserInformation!P2&",dc="&UserInformation!Q2&",dc="&UserInformation!R2&" -samid "&UserInformation!S2&" -upn "&UserInformation!T2&" -fn "&UserInformation!U2&" -ln "&UserInformation!V2&" -desc "&UserInformation!W2&" -display "&UserInformation!X2&" -pwd "&UserInformation!Y2&" -office "&UserInformation!Z2&" -email "&UserInformation!AA2&" -loscr "&UserInformation!AB2&" -mustchpwd "&UserInformation!AC2&" -disabled "&UserInformation!AD2
Copy this down as many rows as needed. Once this information is populated with values from the UserInformation tab, you can copy this to a BAT or CMD file and execute. Modify as needed to change values for groups. The command actually looks something like:
dsadd user cn=0,ou=users,ou=YOUROU,dc=xx,dc=company,dc=com -samid 0 -upn @xx.company.com -fn 0 -ln 0 -desc "" -display " " -pwd changeme -office Location -tel 0 -email .@xx.company.com.com -loscr login.bat -mustchpwd No -disabled Yes
We created the new users as disabled so we could add them to groups as needed and then train them on how to use their new logins.
Last Wiki Answer Submitted:  May 7, 2013  7:00 pm  by  Michael Tidmarsh   14,060 pts.
All Answer Wiki Contributors:  Michael Tidmarsh   14,060 pts. , Labnuke99   32,735 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Will these be users and groups in Active Directory? What functional level is the domain and what windows server versions are in the domain? What server version levels are the DC’s?

 56,975 pts.

 

yes it will be in active directory, and all of this is for my own it improvement so i am implementing everything on a virtual machin with a microsoft xp OS installed

 40 pts.

 

i need to be capable of using a text file with a list of name and groups. the batch file i would like to creat would need to take this list of names (users) and department (groups) and to implament one after the other a new user name (which will be there own name on the list) and put them within their rightfull group (which will be between 3 departments) the list i am trying to use is 26 names and 3 different deppartments where the departments are not in alphabetical order from top to bottom in the list.

 40 pts.

 

DSADD is your friend then. We did this for several thousand users in our environment. Did this for initial group setups also.

 32,735 pts.

 

But do you have a sample .xls or .csv file I could look at? I’m having trouble figuring out what goes on tab1 and what goes on tab2.

 10 pts.

 

Tab 1 would be the user details with the columns designated as shown above. Some are values and others are formulas. Tab 2 is all formulas with one line for each user detail from tab 1.

 32,735 pts.

 

I have the same problem and my teacher said the script should use a text file with the format below. All I remember is the type on top of it and it works. Please help.

these the format he was saying
***********************************************************
New Employees
***********************************************************
Name employeeID Department
Ann A003 News
Betty B005 Distribution
Bob B006 Sales
Charlie C007 News
Deb D017 Printing
Edmund E002 Sales
Fred F010 News
Greg G001 News
Harriet H002 Printing
Isobel I001 Printing
Jane J018 Sales
Kyle K013 Sales
Lynn L007 Distribution
Lynn L008 Distribution
Mike M004 News
Nancy N009 Printing
Onslow O001 Shipping
Pat POO5 News
Qui Q001 News
Roger R004 Printing
Sarah S006 Sales
Ted T007 Distribution
Uwe U001 Printing
Virginia V001 News
Wally W002 Printing
Xerxes X003 Sales
Yolanda Y005 Printing
Zoraster Z067 Distribution

 10 pts.