So if someone has a list of 200 names and they want to quickly add ActiveDirectory users and Exchange mailboxes for each one, are there any tools/techniques that can help with that?

Details:

  • Exchange 2003
  • List of 200 names in Excel/CSV file
  • Add an AD user
  • Then add an Exchange mailbox
  • External contacts needed for each user, with email address
  • Enable dual delivery for each mailbox
link|improve this question

75% accept rate
feedback

3 Answers

up vote 2 down vote accepted

VBScript and ADSI for creating the user accounts. Use something like this to get started:

Set objRootDSE = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://cn=Users," & objRootDSE.Get("defaultNamingContext"))

For i = 1 To 1000
    Set objLeaf = objContainer.Create("User", "cn=UserNo" & i)
    objLeaf.Put "sAMAccountName", "UserNo" & i
    objLeaf.SetInfo
Next

WScript.Echo "1000 Users created."

From here.

The Microsoft Technet Script Center also has loads of sample scripts for just about anything you might wish to do, and is a great resource.

For mailboxes I wouldn't bother scripting; just create all the users in the same OU, then block-select them (in ADU&C), right click, and do the "Exchange Tasks" thing - much quicker and less prone to error.

link|improve this answer
Thanks, this got my Support colleague started, and now he has become a scripting ninja – codeulike Oct 27 '09 at 22:05
feedback

If you don't want to use VBScript, you can also use dsadd. I have a one line batch file that imports all of my new users every year:

(There might be a better way to display this, but I haven't had coffee yet.)

for /F "tokens=1,2,3,4 delims=," %%i in (freshmen09.csv) do dsadd user "cn=%%j %%i,ou=2013,ou=students,dc=[domain],dc=org" -samid %%k -pwd "%%l" -upn %%k@[domain].org -fn "%%j" -ln "%%i" -display "%%j %%i" -memberof "cn=GL 2013,ou=2013,ou=students,dc=[domain],dc=org" -disabled no -mustchpwd yes -hmdrv U: -hmdir "\\[network home directory]\2013\%%k"

This take 4 columns from a CSV file: Last Name, First Name, Username, Password

  • It creates a user for each row in the file,
  • Puts them into the desired OU,
  • Sets the password,
  • Adds them as a member of a group,
  • Enforces that the password must be changed when the user first logs in,
  • Sets the home directory to the appropriate place on our network share.

I have tried to get this to create email addresses automatically, but I have had inconsistent results. Usually I have to do as mh suggested and just select all in ADU&C and setup Exchange Mailbox from there. Very simple, and much easier than figuring that part out with DSADD.

DSADD has many other parameters as well. You can basically make it set any user properties that you want. Simple, easy, and fast.

One failure: Username collisions need to be handled manually. We occasionally have students with names like James Smith and Jonathon Smith. If you have a system to prevent collisions ahead of time, perfect. If not, I recommend redirecting the output of the bat file to a text file and just search for "Fail" in the results.

freshmen09.bat > freshmen09_output.txt

(There is likely a much better way to do this part...)

link|improve this answer
Props for using a batch file but wouldn't you rather use powershell? – Knox Oct 22 '09 at 12:47
Probably, but I set this up when administration couldn't(wouldn't?) give me a list of incoming freshmen until the day after classes started, then wondered why they didn't have accounts yet... Needed to work quickly, and then it worked, so I haven't gone back to update/improve. One day, one day. – minamhere Oct 22 '09 at 13:33
+1 using batch to script commands. I actually perfer batch over powershell, it's easier to read/maintain. – JamesBarnett Dec 27 '10 at 15:45
feedback

VBScript is the way.

Using VBScript and ADSI you can automate most of these tasks.

A couple of links to get you started:

creating a user in AD and alot more

scripting exchange

Have fun!

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.