Avatar of Jerry Seinfield
Jerry Seinfield
 asked on

Bulk creation of contacts in Exchange given a CSV file

Hello Experts,

I have a request for bulk creation of contacts in Exchange given a CSV file. The CSV file has the following structure:

Displayname      Email      FirstName       LastName

is there a Exchange powershell cmdlet or script to import a CSV and create all the contacts in Exchange into a Specific OU in AD?

btw, we do have Exchange 2010 SP1 in PROD, and all our servers runs Windows server 2008 R2

Please advise
PowershellExchangeActive Directory

Avatar of undefined
Last Comment
Manpreet SIngh Khatra

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Manpreet SIngh Khatra

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jerry Seinfield

ASKER
Hi Randy,

i ran the command above, and got an error, as displayed on attached file

Any ideas?
ErrorImportContacts.png
Jerry Seinfield

ASKER
here is the command i did run

Import-Csv ExchangeExternalContacts.csv | ForEach { New-MailContact -Name $_.DisplayName -Firstname $_.FirstName -LastName $_.LastName -ExternalEmailAddress $_.EmailAddress -OrganizationalUnit "OU=Contacts,OU=External Users,OU=XXX Users,DC=XXX,DC=XXX,DC=XXX,DC=XXX" }
Manpreet SIngh Khatra

ExternalEmailAddress - i guess its ExternalEmailAddresses

Just check this once for only 2 contacts ..... not more (First test always with only few so if issues its simple to delete)

- Rancy
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Manpreet SIngh Khatra

ExternalEmailAddress - Do you have the data filled for this in the CSV ? as it says "because its null"

- Rancy
Jerry Seinfield

ASKER
Hi Rancy,

I did test with only 2 users and did not work.

The original file has around 100 contacts that must be created, so the CSV file is filled wit this information

Just to clarify, I am trying to create external mail contacts, these users do not belong to my domain, and they do not have any account in our AD domain, just need the contacts created
Manpreet SIngh Khatra

Do you have the information for ExternalEmailAddress entered in the CSV file

- Rancy
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Jerry Seinfield

ASKER
Yes,
I did find another blog with same issue,

https://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_27801526.html

so, should I add an Alias to my command?, please check below my final cmdlet

Import-Csv "C:\ExternalContacts.csv" | ForEach { New-MailContact -Name $_.DisplayName -Firstname $_.FirstName -LastName $_.LastName -ExternalEmailAddress $_.EmailAddress -Alias $_.Alias -OrganizationalUnit "OU=XXX,OU=XXX,OU=XXX XXX,DC=XXX DC=XXX,DC=XXX,DC=XXX" }  

The .CSV file column headers are:

Displayname, First Name, Last Name, ExternalEmailAddress, Alias

What do you think?

Any other recommendations?
SOLUTION
Manpreet SIngh Khatra

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question