The Problem: A good number of people's info was added to my "Mail Contact" list in Exchange Management Console, but not all.
Summary: I'm attempting to add a list of several hundred people from a excel .csv file into my Exchange Management Console (Mail contacts more specifically). A number of the contacts may Already be in the contact list which may have caused my foreach statement to stop running?
My Question: Is there code I can run to check if the members exist then if not, add the member?
I ran this code in powershell in this format:
Import-Csv .\computech.csv | foreach { New-MailContact -Name $_.displayname -FirstName $_.firstname -LastName $_.lastname -ExternalEmailAddress $_.mail -OrganizationalUnit $_.OrganizationalUnit}
Strangely enough it added a good number of the people from the list but not all of them. When I try to run the code now I get this error:
Import-Csv : The member "Aaron" is already present.
"Aaron" is the first member on the list and so the execution immediately stops there
I had previously tried this using this code:
[PS] C:\Windows\system32>Import-Csv \\FILLER\MailboxBackups\contacts.csv | foreach-object{if (Get-MailContact -External
EmailAddress $_.ExternalEmailAddress){write-host $_.ExternalEmailAddress 'is a duplicate entry!!!!'} else {New-MailConta
ct -Name $_.Name -ExternalEmailAddress $_.ExternalEmailAddress -FirstName $_.FirstName -LastName $_.LastName}}
But I received the same "Aaron" is already present error lol. Any help would be greatly appreciated
--------UPDATE------------ I found out that not all of the contacts were added because of Alias conflicts. Aliases were common names like "bob" which are sure to already exist. Do people normally use numbers to get around this, or use a users email address instead of simple names?