Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Exchange / Export Exchange or Office 365 Global Address List (GAL) to CSV

December 6, 2021 ExchangeMicrosoft 365Office 365OutlookPowerShell

Export Exchange or Office 365 Global Address List (GAL) to CSV

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.

Contents:
  • How to Export Global Address List to CSV in On-Prem Exchange Server?
  • Exporting Global Address List from Exchange Online (Microsoft 365)
  • Export Global Address List from Outlook or Access

How to Export Global Address List to CSV in 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.

exchange admin center on-premises: export address list to csv file

Next, you can select properties (attributes) of users you want to export to a CSV file.

exporting user email adresses to csv in exchange

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

Powershell Get-Recipient

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

Get-Recipient results are limited to 1000 objects. To get more addresses, use the -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]
You can use the PowerShell cmdlets Get-ADUser and Get-ADGroup from the AD PowerShell module to get a list of users and groups with SMTP addresses. Let’s export a list of users with SMTP addresses (proxyaddresses AD attribute) from a specific OU:

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.

office365 (microsoft 365): export mailbox list to excel or csv file

Similarly, you can export a list of contacts, distribution lists, 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 EXO v2 module:

Connect-ExchangeOnline

List the available Global Address Lists using the command:

Get-GlobalAddressList | Select-Object Name

Get-GlobalAddressList - powershell

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

export global address list with powershell to csv in exchange online

All possible types of recipients in Exchange Online have been exported to the CSV file: UserMailbox, MailUser, MailUniversalDistributionGroup, MailContact, 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 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.

adding global address list to personal contacts in outlook

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.

  1. Run Microsoft Access and select File->Open in its menu;
  2. Select Exchange() in file types;Connect Exchange via Access
  3. In the list of sources select Global Address List; Import Exchange GAL to Microsoft Access
  4. You will get a flat Access table with data from the Exchange address book;
  5. 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
2
Facebook Twitter Google + Pinterest
previous post
High Non-Paged Pool Memory Usage (Leak) in Windows
next post
How to Connect to Azure AD Using PowerShell?

Related Reading

How to Connect VPN Before Windows Logon

November 14, 2023

Send Emails with Microsoft Graph API and PowerShell

November 6, 2023

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

2 comments

tondalaeois March 30, 2016 - 9:13 am

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
 

Reply
TheBigT42 February 14, 2020 - 9:03 pm

PowerShell

Get-mailbox -results unlimited | Where-Object {$_.AddressListMembership -like “*Default Global Address List*”} | Select-Object DisplayName,UserPrincipalName,AddressListMembership,HiddenFromAddress | export-csv gal.csv

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • How to Connect VPN Before Windows Logon

    November 14, 2023
  • Removing Azure Arc Setup Feature on Windows Server 2022

    November 9, 2023
  • Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

    November 7, 2023
  • Send Emails with Microsoft Graph API and PowerShell

    November 6, 2023
  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Outlook Keeps Asking for Password on Windows
  • How to Manually Configure Exchange or Microsoft 365 Account in Outlook 365/2019/2016
  • Moving Exchange Mailboxes to Different Database
  • FAQ: Licensing Microsoft Exchange Server 2019/2016
  • Whitelist Domains and Email Addresses on Exchange Server and Microsoft 365
  • How to Cleanup, Truncate or Move Log Files in Exchange Server 2013/2016/2019?
  • Search and Delete Emails from User Mailboxes on Exchange Server (Microsoft 365) with PowerShell
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top