Import Exchange Online Contacts and Hide Them from the GAL
Question details
Import external contacts from a CSV file into Exchange Online and hide them from the Global Address List.
- Product
- Exchange Online
- Device & OS
- not provided
- Scenario
- An administrator needs to bulk-create external mail contacts without displaying them in address lists.
- Observed behavior
- New-MailContact does not recognize the parameter used to hide contacts from address lists.
Prepare a CSV with Name, ExternalEmailAddress, FirstName, and LastName columns, and check that the email addresses uniquely identify the contacts. Use an account with permission to create and modify mail contacts, and connect to Exchange Online PowerShell.
Create the contacts, then hide them with Set-MailContact
Use separate Exchange Online PowerShell commands because the visibility setting cannot be applied with New-MailContact.
Open PowerShell, install the ExchangeOnlineManagement module if needed with Install-Module ExchangeOnlineManagement, and run Connect-ExchangeOnline. Sign in with an authorized administrator account.
Replace the path below with your CSV file path and run: $contacts = Import-Csv "C:\path\contacts.csv" foreach ($contact in $contacts) { try { New-MailContact -Name $contact.Name -DisplayName $contact.Name -ExternalEmailAddress $contact.ExternalEmailAddress -FirstName $contact.FirstName -LastName $contact.LastName -ErrorAction Stop Set-MailContact -Identity $contact.ExternalEmailAddress -HiddenFromAddressListsEnabled $true -ErrorAction Stop } catch { Write-Warning "Could not create or hide $($contact.ExternalEmailAddress): $_" } }
Run Get-MailContact -Identity "contact@example.com" | Format-List DisplayName,ExternalEmailAddress,HiddenFromAddressListsEnabled for a created contact. Confirm that HiddenFromAddressListsEnabled is True, and repeat for other contacts as needed.
Prepare your contact CSV with WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for preparing contact data. Its Microsoft Office format compatibility makes it easy to move existing files into WPS; Exchange Online PowerShell is still required to import and hide contacts.

Frequently Asked Questions
Why doesn't HiddenFromAddressListsEnabled work with New-MailContact?
New-MailContact does not accept that parameter. Create the mail contact first, then run Set-MailContact -Identity "contact@example.com" -HiddenFromAddressListsEnabled $true.
How can I check whether a contact is hidden?
In Exchange Online PowerShell, run Get-MailContact -Identity "contact@example.com" | Format-List DisplayName,HiddenFromAddressListsEnabled. The setting should show True.
Does hiding a contact prevent people from emailing it?
No. Hiding a contact removes it from address lists; it does not prevent someone who knows the address from sending email to it.
What should I do if a contact was created but was not hidden?
Check the PowerShell warning, resolve the reported issue, and run Set-MailContact -Identity "contact@example.com" -HiddenFromAddressListsEnabled $true. Then verify the setting with Get-MailContact.




