Link to home
Start Free TrialLog in
Avatar of Wolf
WolfFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Script to update AD Users Email Address using Firstname and Lastname

Hi

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:

james.bond@test.com

but obviously with our domain

Any ideas?

Thanks

Andrew
Avatar of MHITSupport
MHITSupport

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
ps: if no exchange, use vbscript and ADSI to populate the email addresses
Avatar of Wolf

ASKER

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
yes,
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)
Avatar of Wolf

ASKER

Thanks for the reply but i've never written a script in my life, wouldn't know where to begin...
ASKER CERTIFIED SOLUTION
Avatar of X-treem
X-treem
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
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