[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Script to update AD Users Email Address using Firstname and Lastname

Posted on 2012-04-13
9
Medium Priority
?
219 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
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 to another domain controller. Log onto the new domain controller with a user account t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

649 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