Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add non-exchange email address to existing users in Active Directory

Posted on 2016-08-22
7
Medium Priority
?
60 Views
Last Modified: 2016-08-23
Hi.  I need to add a gmail address to some of my existing AD users.  I think it can be done using the Set-ADUser -Add command in powershell but i can't figure out the rest of the commands.  Ideally i would want the Set-ADUser command to cross reference a csv file with all of the usernames and email addresses listed.  If anyone can help that's be great, Please don't forget the layout for the csv file.  Thanks.

Dave
0
Comment
Question by:tech218
[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
  • 4
  • 2
7 Comments
 

Expert Comment

by:Michael Nieto
ID: 41765893
Try this powershell script:
Add-Content c:\debug.txt "::Starting Import: "; 

$err = ""; 

Import-Csv contacts.csv | ForEach-Object{ 

$contact = Get-MailContact $_."displayname" -DomainController YOURDOMAIN.COM 
$contact.EmailAddresses += $_."ex" 
$contact | Set-MailContact 
} 
Add-Content c:\debug.txt $err;

Open in new window

0
 
LVL 16

Accepted Solution

by:
FOX earned 2000 total points
ID: 41765903
2 columns- at the top of your adusers column name it users, the other column with the email address just name it address
users,address
johndoe,jdoe@gmail.com

Save the file as emailaddresses.csv

$Users=Import-csv "c:\filelocation\emailaddresses.csv" | foreach{Get-Aduser $_.users | Set-Aduser -emailaddress $_.address}
0
 

Author Comment

by:tech218
ID: 41765919
I really do appreciate your time but that is very confusing to me...

I need to update users based on username (sAMAccountName?) not displayname (am i reading that right?)
What is the debug.txt file?  Does it act as an error log?  Does it log what user accounts were changed\failed?
What information is in the .csv file?  Is it "sAMAccountName" plus "sAMAccountName@domain.net"?  What are the headers or does it need headers?

Does this make sense?  Thanks.

D.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:tech218
ID: 41765942
FoxLUV, thanks for the post.  I have a question.  Is this what you meant for the column headings?

Column1=users
Column2=addressusers,address

Please correct if wrong.  Thanks.

D.
0
 

Author Comment

by:tech218
ID: 41765968
Foxluv, I figured it out based on common sense and a successful test...When i do this en masse, i will let you know the results.  Thanks.

D.
0
 

Author Closing Comment

by:tech218
ID: 41767075
Worked like a champ!  Over 5500 users now have an email address associated with their logon.  Thanks.
0
 
LVL 16

Expert Comment

by:FOX
ID: 41767101
Nice work!!!!
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
A hard and fast method for reducing Active Directory Administrators members.
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 to another domain controller. Log onto the new domain controller with a user account t…

610 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