Solved

Script to update AD Users Email Address using Firstname and Lastname

Posted on 2012-04-13
9
204 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:Tony
9 Comments
 

Expert Comment

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

Expert Comment

by:Anuroopsundd
Comment Utility
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
Comment Utility
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
 
LVL 8

Expert Comment

by:X-treem
Comment Utility
ps: if no exchange, use vbscript and ADSI to populate the email addresses
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:Tony
Comment Utility
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
Comment Utility
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:Tony
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Installing a printer using group policy preferences is not that hard let’s take a look at it. First lets open up your group policy console and edit the policy you want to add it to. I recommend creating a new policy for each printer makes it a l…
Introduction You may have a need to setup a group of users to allow local administrative access on workstations.  In a domain environment this can easily be achieved with Restricted Groups and Group Policies. This article will demonstrate how to…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

762 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now