Belkin 13U Mini EnclosureSo I inherited this 3-campus school network a few months back, and it’s not in the best shape; Active Directory is a mess. This is both because it hasn’t been maintained too well, and the computer accounts are messed up from the improper use of Ghost 2003. (I’ll get into that in another post)

So I kinda want to re-do the entire active directory structure, but I have to wait until June or so. For now, though, I need to add in about 60 first graders and about 45 kindergateners (they need their own accounts to get an H: drive that holds their drawings in paint of spiderwebs, monkeys etc.

I could spend a lot of time manually making these accounts, but over time, humans have a habit of making small mistakes while doing repetitive tasks. And it’s boring. So, I’ll use a .csv file to make the text for a couple batch files. These batch files will run on the server, add the accounts to AD, and set the password, H: drive, etc.

I’ve entered in all of their names in an OpenOffice Calc .csv file as follows:
(we use high school graduation year to signify grade. Seniors are 2006, Kindergarten is 2018. It’s not a good system…this summer…breathe…)

Prepping the feeder file

fname,lname,hs-gradyear,login-id,password
john,doe,2018,=CONCATENATE(RIGHT(B3,2);LEFT(B1,1);B2),password

You can see I’m using a formula to determine login name. In this case, the login name becomes 18JDoe. I’ll name this sheet ‘Data’

Making the folders

They will all need folders on the server so I can make their H: drive folders at \\server\login-name$. But first I have to make the folders. Building off of my student list, I make a new sheet in the same file and make the following:

mkdir,=CONCATENATE(“D:\Users\Students\”;=$Data.B4)

this ends up looking like this:

mkdir,D:\Users\Students\17JDoe

When I’ve copied this formula to all of the rows and proofread them, I will open the csv in notepad and replace ‘,’ with ‘ ‘ (space). This makes my notepad file a list of lines that look like this:

mkdir D:\Users\Students\17JDoe

which, of course, makes folders when you save this text file as a .bat and run it on the server.

Making the shares

Using the same method, I make a csv via formula that reads:

rmtshare,\\server\login-id$=D:\Users\Students\17JDoe,/GRANT,17JDoe:f

Open in notepad and replace ‘,’ with ‘ ‘, and you get a batch file that says:

rmtshare \\server\login-id$=D:\Users\Students\17JDoe /GRANT 17JDoe:f

There are many other options I do with the rmtshare command related to security, but I’ve left them off here. You might want to check it out.
Making the accounts

This is the big one. Here is what the line looks like for our test user:
(I’m splitting the cells onto seperate lines for readability)

net,user,17JDoe,123,/add,
/comment:”John Doe, class of 2017″,
/expires:07/01/2017,
/fullname:”John Doe,
/homedir:\\server\17JDoe$,
/scriptpath:login.bat,
/times:M,7AM-4PM;T,7AM-4PM;W,7AM-4PM;Th,7AM-4PM;F,7AM-4PM

(we limit students to times when there is supervision in the lab)

Open up in notepad, replace ‘,’ with ‘ ‘, and save as .bat. Run on server. Done. 105 accounts made in 10 minutes, no mistakes.

Related: