Solved

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

Posted on 2016-08-22
7
42 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
Does Powershell have you tied up in knots?

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
A brief introduction to what I consider to be the best editor for PowerShell.
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 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