Solved

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

Posted on 2016-08-22
7
32 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
  • 4
  • 2
7 Comments
 

Expert Comment

by:Michael Nieto
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:tech218
Comment Utility
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
Comment Utility
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
Comment Utility
Worked like a champ!  Over 5500 users now have an email address associated with their logon.  Thanks.
0
 
LVL 16

Expert Comment

by:FOX
Comment Utility
Nice work!!!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Synchronize a new Active Directory domain with an existing Office 365 tenant
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…

743 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

12 Experts available now in Live!

Get 1:1 Help Now