?
Solved

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

Posted on 2016-08-22
7
Medium Priority
?
51 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Here's a look at newsworthy articles and community happenings during the last month.
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
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 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 …
Suggested Courses

801 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