Let’s consider some ways of exporting the Exchange Global Address List (GAL) or Offline Address Book to a text CSV file. GAL contains all email addresses of your on-prem Exchange organization or Exchange Online (Office 365) tenant. You can use the CSV file with the contact list from the corporate address book to transfer and import contacts to third-party email clients or email services.
Let’s deal with some export tools: these can be Exchange Admin Center, PowerShell, MS Access, Outlook, or csvde utility.
How to Export Global Address List to CSV in an On-Prem Exchange Server
The easiest way is to export the address list directly from the Exchange Admin Center (EAC) console. To do this, go to Recipients -> Mailbox section, click …, and select Export data to a CSV file.
Next, you can select the properties (attributes) of users you want to export to a CSV file.
But, you can export only users’ email addresses in this way. To export addresses of distribution groups, you need to go to Groups and export from there (similarly to Contacts, Resources, Shares).
To get the address list in the domain, you can use the PowerShell cmdlet Get-Recipient. For example, our task is to display the list of user names, their SMTP addresses, and phone numbers. Connect to your Exchange Server from PowerShell and run the command:
Get-Recipient| Select-Object Name,PrimarySmtpAddress, Phone
To display only the Default Global Address List entries, use this filter:
$filter = (Get-GlobalAddressList 'Default Global Address List').RecipientFilter
Get-Recipient -ResultSize unlimited -RecipientPreviewFilter $filter | Select-Object Name,PrimarySmtpAddress, Phone
-ResultSize Unlimited
parameter.To exclude from the list the entries hidden from the address book (HiddenFromAddressLists attribute). User the Export-CSV cmdlet in order to export results to the CSV file:
Get-Recipient -RecipientPreviewFilter $filter | Where-Object {$_.HiddenFromAddressListsEnabled -ne $true} | Select-Object Name,PrimarySmtpAddress, Phone | Export-CSV c:\exchange\GAL.csv -NoTypeInformation
You can also export the list of mailboxes in GAL as follows:
Get-mailbox -results unlimited | Where-Object {$_.AddressListMembership -like “*Default Global Address List*”} | Select-Object DisplayName,UserPrincipalName,AddressListMembership,HiddenFromAddress
To export data from Active Directory, you can use the csvde.exe console tool.
The command to display user data with their e-mail addresses can look like this:
CSVDE -r "(&(objectClass=person)(mail=*))" -l displayName,proxyAddresses –f Exchange-GAL.csv
As a result, you get an address list like this:
“CN=LondTest,OU=Service,DC=corp,DC=woshub,DC=com",LondTest,smtp: [email protected]
Get-ADUser -Filter * -SearchBase 'OU=London,OU=UK,DC=woshub,DC=com' -Properties proxyaddresses | Select-Object Name, Proxyaddresses| Export-CSV C:\PS\AD_OU_Export_GAL.csv
Exporting Global Address List from Exchange Online (Microsoft 365)
There are no built-in tools to export all GAL content in the Exchange Online web interface (https://admin.exchange.microsoft.com/). However, you can export a list of user mailboxes, distribution groups, or resource mailboxes to a CSV file one by one. To do this, go, for example, to Recipient -> Mailboxes, and select Export.
Similarly, you can export a list of contacts, distribution lists, and mail-enabled groups.
It is much easier and more convenient to export the Global Address List from your Exchange Online (Microsoft 365) tenant using PowerShell. Connect to your Exchange Online tenant with the EXO v3 module:
Connect-ExchangeOnline
List the available Global Address Lists using the command:
Get-GlobalAddressList | Select-Object Name
In our example, only the ‘Default Global Address List’ exists. This address list includes all mail-enabled objects in the organization (users, groups, distribution groups).
Let’s get the filter of the Global Address List:
$Filter = (Get-GlobalAddressList 'Default Global Address List').RecipientFilter
The following filter is used to add objects to the GAL:
((Alias -ne $null) -and (((ObjectClass -eq 'user') -or (ObjectClass -eq 'contact') -or (ObjectClass -eq 'msExchSystemMailbox') -or (ObjectClass -eq 'msExchDynamicDistributionList') -or (ObjectClass -eq 'group') -or (ObjectClass -eq 'publicFolder'))))
Now you can get a list of all SMTP addresses from the Exchange Online tenant and export them to a CSV file:
Get-Recipient -RecipientPreviewFilter $Filter | Select-Object Name, PrimarySmtpAddress,RecipientType | Export-CSV C:\PS\Export_Office365_GAL.csv -NoTypeInformation
All possible types of recipients in Exchange Online have been exported to the CSV file: UserMailbox, MailUser, MailUniversalDistributionGroup, MailContact, and DynamicDistributionGroup.
Export Global Address List from Outlook or Access
If you don’t have privileged permissions in Exchange, you can export the organization’s global address list from the user’s computer using programs from MS Office/Office 365.
You cannot export the contents of the Global Address List directly from Outlook. The only workaround for exporting GAL content to a file is to add all recipients from the organization’s address book to the personal Contacts list (Address Book –> Global Address List -> CTRL+A -> Add to contacts). Then you can export Outlook contacts to CSV via the Import-Export feature (File -> Open & Export -> Import/Export). You will have to copy the original contacts to an Outlook temporary contact folder. As you can see, this method is not very convenient.
And finally, the least evident, but quite simple and clear way to export the GAL for a non-admin user is to use an Exchange connection in Microsoft Access.
- Run Microsoft Access and select File->Open in its menu;
- Select Exchange() in file types;
- In the list of sources select Global Address List;
- You will get a flat Access table with data from the Exchange address book;
- Now you can export this data from the database to a CSV file.
All you have to do is import the CSV file you received in Excel and modify it as you need.
2 comments
Great post!
You can also export using Outlook or GUI Exchange admin tools:
http://www.sysadmit.com/2016/03/exchange-exportar-lista-global-de-direcciones.html
PowerShell
Get-mailbox -results unlimited | Where-Object {$_.AddressListMembership -like “*Default Global Address List*”} | Select-Object DisplayName,UserPrincipalName,AddressListMembership,HiddenFromAddress | export-csv gal.csv