Solved

Script to update AD Users Email Address using Firstname and Lastname

Posted on 2012-04-13
9
214 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:Wolf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 

Expert Comment

by:MHITSupport
ID: 37841730
try selecting all users from the ou and for the email field use %firstname%.%lastname%@domain.com ?
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37841738
Do you have exchange server?
which version of active directory server?
can it be powershell command if 2008 server?
0
 
LVL 8

Expert Comment

by:X-treem
ID: 37841739
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
0
Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

 
LVL 8

Expert Comment

by:X-treem
ID: 37841741
ps: if no exchange, use vbscript and ADSI to populate the email addresses
0
 
LVL 1

Author Comment

by:Wolf
ID: 37841969
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
0
 
LVL 8

Expert Comment

by:X-treem
ID: 37842100
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)
0
 
LVL 1

Author Comment

by:Wolf
ID: 37842592
Thanks for the reply but i've never written a script in my life, wouldn't know where to begin...
0
 
LVL 8

Accepted Solution

by:
X-treem earned 500 total points
ID: 37842677
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
0
 
LVL 9

Expert Comment

by:Scottyworld
ID: 37858925
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
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question