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?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

try selecting all users from the ou and for the email field use ?
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
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Very easy in just a few lines of script. Do you definitely want the email address to be ?

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.