Solved

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

Posted on 2016-08-22
7
35 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
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 500 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
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.

 

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 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

24 Experts available now in Live!

Get 1:1 Help Now