• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Script to update AD Users Email Address using Firstname and Lastname


In one of our OU's on Active Directory all the users have nothing displayed in the Email Address field of User account propertys general tab.

Is it possible to create a script that completes this field using the users first name and last name?

So if the users is called James Bond, the script will add the email address to the field like this:


but obviously with our domain

Any ideas?


1 Solution
try selecting all users from the ou and for the email field use %firstname%.%lastname%@domain.com ?
Do you have exchange server?
which version of active directory server?
can it be powershell command if 2008 server?
make a recipient policy in exchange that only affects the OU and specify the desired smtp address
apply the policy and the email addresses should follow
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

ps: if no exchange, use vbscript and ADSI to populate the email addresses
WolfAuthor Commented:
We dont have Exchange, Lotus Notes

I know i have to use vbscript, but i dont know how

I have an excel spreadsheet with a list of usernames and email addresses, is there a way to import that to AD using vbscript?

It's Server 2008 for AD
save the excel file as a csv file (username, mail)

vbscript basics:
- read excel file
- split lines to array (user/mail)

connect for each user to AD using adsi and set email address
log the progress to a tet file/screen so that you know what happens (and if it gets stuck, where to continue)
WolfAuthor Commented:
Thanks for the reply but i've never written a script in my life, wouldn't know where to begin...
use google and split up your script in parts, when done assemble them into 1:
so that you understand what is happening and how to do it

part 1 : read a text file
part2 : write a text file (for logging)
part 3: create an array
part 4: read text file to array (script)
part 5: read email address from AD (using ADSI)
part 6: write email address using adsi

then you can combine all steps
Very easy in just a few lines of script. Do you definitely want the email address to be firstname.lastname@yourdomain.com ?

Does that OU have a unique name in Active directory? We want to make sure we target the correct OU and not all OU's that have a name of 'users' for example
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now