question

Kailin-1236 avatar image
0 Votes"
Kailin-1236 asked joyceshen-MSFT commented

Could I add more than 200 email contacts in the Default Global Address list by using powershell at once?

I got two questions about the Global Address list here:

  1. I get more than 200 email contacts and want to add into the Default Global Address list at once by using PowerShell . But it only allowed me to add 40 contacts each times which not efficiency. Is there any way to do that at once?


  2. Does the GAL allows the duplicate email address? Since we have clients that have several members share one email. So If there's any way that could make Outlook 2016 or GAL allow to create duplicate email address?

Thank you!







office-exchange-server-administrationwindows-server-powershelloffice-outlook-itpro
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Kailin-1236

Have you referred to the replies below? Any update here?

0 Votes 0 ·

Hi @Kailin-1236

Is your issue resolved now? Any further information so far?

0 Votes 0 ·
RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

You should be able to add as many contacts to the Active Directory as you want using the New-Mailcontact cmdlet.

The Global Address List is managed by Exchange server. If a mail-enabled object isn't showing up in the GAL it may be because it's been hidden from the GAL. If that's the case you can use the Set-Mailcontact cmdlet and the HideFromGlobalAddressList parameter to allow its inclusion in the GAL.

The GAL is updated only periodically, so don't expect it to show up immediately.

The GAL just uses what's in the AD. Exchange shouldn't allow the same email address to be used in more than one mail- or mailbox-enabled object. Email addresses must be unique.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered LimitlessTechnology-2700 published

Hello,

I don`t think this will be an easy one. To bulk import contacts, one of the efficient ways is to use PowerShell. Here are the instructions on how to use PowerShell for importing multiple contacts using a .csv file

Gathering Contacts

1.Create a contact CSV (comma-separated value) file containing the following headers.

ExternalEmailAddress

Name

FirstName

StreetAddress

City

StateorProvince

PostalCode

Phone

MobilePhone

*Type in precisely as mentioned above.

2.Please note that you must provide an email address [ExternalEmailAddress] for each contact. If any of the employees do not have an email address, exclude those records from this list because those cannot be processed and imported.

You must fill out these two mandatory columns for each contact.

ExternalEmailAddress
Name
*The other columns are optional. If any column is left blank, it will not be imported into the GAL.

Code execution and its explanation:

PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned (Setting Up Execution Policy and set it RemoteSigned).

Execution Policy Change

The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic at

http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?

[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y

(Set it to Yes or Yes to All )

PS C:\Windows\system32> $UserCredential=Get-Credential (Provide the server administrator credentials)

PS C:\Windows\system32> $s=New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ** -credential $UserCredential -Authentication Basic -AllowRedirection

PS C:\Windows\system32> import-PSSession -session $s

(Importing the session so that all the commands like New-MailContact, New-MailBox, etc. controls can operate on cmd script)

creating the system pop-up dialog box for importing the CSV file. Please note ‘param’ might show warning messages, but you can ignore it.

 param(
    
     [Parameter(ValueFromPipeline=$true,HelpMessage="Enter CSV path(s)")]
    
     [String[]]$Path = $null
    
 )
    
 if($Path -eq $null) {
    
     Add-Type -AssemblyName System.Windows.Forms
    
     $Dialog = New-Object System.Windows.Forms.OpenFileDialog
    
     $Dialog.InitialDirectory = "$InitialDirectory"
    
     $Dialog.Title = "Select CSV File(s)"
    
     $Dialog.Filter = "CSV File(s)|*.csv"        
    
     $Dialog.Multiselect=$true
    
     $Result = $Dialog.ShowDialog()
    
     if($Result -eq 'OK') {
    
         Try {
    
             $Path = $Dialog.FileNames
    
         }
    
         Catch {
    
             $Path = $null
    
             Break
    
         }
    
     }
    
     else {
    
         #Shows upon cancellation of Save Menu
    
         Write-Host -ForegroundColor Yellow "Notice: No file(s) selected."
    
         Break
    
     }
    
     $Date = Get-Date
    
 Write-Host "You input:'$Path' on '$Date'"
    
 }

Display the CSV file imported.

Import-Csv $Path

Uploading the imported CSV file.

Import-Csv $Path |%{New-MailContact -Name $.Name -DisplayName $.Name -ExternalEmailAddress $.ExternalEmailAddress -FirstName $.FirstName - $_.LastName}

Please note the following:

  1. Marked in red (Error message) may come if the contacts are already added in the GA, or there is some error in the CSV file.

  2. In our case, we have added only ExternalEmailAddress and Name. In order to customize more inputs, please modify the command as follows.

Import-Csv $Path |%{New-MailContact -Name $.Name -DisplayName $.Name -ExternalEmailAddress $.ExternalEmailAddress -FirstName $.FirstName -LastName $.LastName -StreetAddress $.StreetAddress} and so on.

Syntax:

-ExternalEmailAddress $_.(CSV File Coloumn Name)

-Name $_.(CSV File Coloumn Name)

-FirstName $_.(CSV File Coloumn Name)

-LastName $_.(CSV File Coloumn Name)

-StreetAddress $_.(CSV File Coloumn Name)

-City $_.(CSV File Coloumn Name)

-StateorProvince $_.(CSV File Coloumn Name)

-PostalCode $_.(CSV File Coloumn Name)

-Phone $_.(CSV File Coloumn Name)

-MobilePhone $_.(CSV File Coloumn Name)

  1. Other parameters which can be used with New-MailContact cmdlet are as follows:

New-MailContact

-Name <String>

-ExternalEmailAddress <ProxyAddress>

[-Alias <String>]

[-ArbitrationMailbox <MailboxIdParameter>]

[-Confirm]

[-DisplayName <String>]

[-DomainController <Fqdn>]

[-FirstName <String>]

[-Initials <String>]

[-LastName <String>]

[-MacAttachmentFormat <MacAttachmentFormat>]

[-MessageBodyFormat <MessageBodyFormat>]

[-MessageFormat <MessageFormat>]

[-ModeratedBy <MultiValuedProperty>]

[-ModerationEnabled <Boolean>]

[-OrganizationalUnit <OrganizationalUnitIdParameter>]

[-OverrideRecipientQuotas]

[-PrimarySmtpAddress <SmtpAddress>]

[-SendModerationNotifications <TransportModerationNotificationFlags>]

[-UsePreferMessageFormat <Boolean>]

[-WhatIf]

[<CommonParameters>]

For more information on parameters, please refer to the link:

https://docs.microsoft.com/en-us/powershell/module/exchange/new-mailcontact?view=exchange-ps

Contacts are now available on the admin console.

You can also copy and paste the complete code on windows PowerShell ISE and save it as .ps1 file and run the same.

Set-ExecutionPolicy RemoteSigned

$UserCredential=Get-Credential

$s=New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ** -credential $UserCredential -Authentication Basic -AllowRedirection

import-PSSession -session $s

 param(
    
     [Parameter(ValueFromPipeline=$true,HelpMessage="Enter CSV path(s)")]
    
     [String[]]$Path = $null

 )
 if($Path -eq $null) {
    
     Add-Type -AssemblyName System.Windows.Forms
    
     $Dialog = New-Object System.Windows.Forms.OpenFileDialog
    
     $Dialog.InitialDirectory = "$InitialDirectory"
    
     $Dialog.Title = "Select CSV File(s)"
    
     $Dialog.Filter = "CSV File(s)|*.csv"        
    
     $Dialog.Multiselect=$true
    
     $Result = $Dialog.ShowDialog()
    
     if($Result -eq 'OK') {
    
         Try {
    
             $Path = $Dialog.FileNames
    
         }
    
         Catch {
    
             $Path = $null
    
             Break
    
         }
    
     }
    
     else {
    
         #Shows upon cancellation of Save Menu
    
         Write-Host -ForegroundColor Yellow "Notice: No file(s) selected."
    
         Break
    
     }
    
     $Date = Get-Date
    
 Write-Host "You input :'$Path' on '$Date'"
    
 }

Write-Host "Displaying Content of the .CSV File. Please remember (ExternalEmailAddress & Name are two default fields to add contacts to exchange and has to be the first two-column). ExternalEmailAddress

Name

FirstName

LastName

StreetAddress

City

StateorProvince

PostalCode

Phone

MobilePhone "

Import-Csv $Path

Import-Csv $Path |%{New-MailContact -Name $.Name -DisplayName $.Name -ExternalEmailAddress $.ExternalEmailAddress -FirstName $.FirstName -LastName $_.LastName}


More Information regarding the topic:

https://docs.microsoft.com/en-us/exchange/address-books/address-lists/address-lists

https://docs.microsoft.com/en-us/exchange/email-addresses-and-address-books/address-lists/address-lists?view=exchserver-2019

https://docs.microsoft.com/en-us/exchange/address-books/address-lists/manage-address-lists

Regards,




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

joyceshen-MSFT avatar image
0 Votes"
joyceshen-MSFT answered

Hi @Kailin-1236

I agree with the reply above from RichMatheisen-8856, mail contacts are included in the Exchange Global Address List (GAL) and Offline Address Book (OAB)

So we could use the method introduced in this article to bulk import mail contacts to your server: Exchange PowerShell: How to Bulk Import/Create Mail Contacts

For your second question, I would suggest you read this article: Preventing duplicate SMTP addresses on Exchange
SMTP addresses need to be unique within your Exchange organization, and we should avoid duplicate addresses in Exchange server

Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.


If an Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.