Solved

Script to update AD Users Email Address using Firstname and Lastname

Posted on 2012-04-13
9
212 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

830 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