Knowledge Base

How to export a list of mailboxes to a CSV file


You need to export a list of mailboxes from an on-premises Exchange server or Exchange Online (Office 365) to a CSV file, for example, to use it with CodeTwo migration software.


There are two ways to prepare a CSV file listing all the mailboxes residing on an Exchange on-premises or Exchange Online server:


If you’re exporting the CSV file to use it in CodeTwo migration software when matching mailboxes, remember to add the target email address to each row. Learn more

We've also prepared PowerShell scripts that will let you generate a CSV file with matched source and target mailbox pairs. See this article for more information: How to generate a CSV file with PowerShell for CodeTwo migration tools

Exporting the mailbox list by using cmdlets

  1. Start ems Exchange Management Shell (on-premises Exchange) or connect to the Exchange server remotely (Office 365).
  2. To get the list of all mailboxes hosted on your Exchange server, execute the following cmdlet:
    $mailboxes = Get-Mailbox -resultSize unlimited
  3. Export the list together with selected AD properties (in this case the user’s first and last name, display name and email address) to a CSV file by using the following cmdlet:
    $mailboxes | foreach { Get-User $_.UserPrincipalName | select FirstName, LastName, DisplayName, WindowsEmailAddress } | export-csv -NoTypeInformation .\Mailboxes.csv -Delimiter ";" -Encoding unicode

    The CSV file will be saved in a folder located in the same path from which the cmdlet was executed.

To limit the number of exported mailboxes to only selected ones, you can use different methods:

  • Use the Get-DistributionGroupMember cmdlet to export members of a certain group, instead of all mailboxes
  • Use filters in the Get-Mailbox command to look only for selected users, for example:
Get-Mailbox -filter "DisplayName -like 'adele*' -or DisplayName -like 'megan*'"

will export only mailboxes of users whose display names include Adele or Megan.

    Exporting the mailbox list by using the Exchange admin center

    On-premises Exchange

    1. Log in to the Exchange admin center as discussed in the instructions for Exchange Server 2019 and 2016 and Exchange Server 2013.

    2. Choose recipients from the feature panel. You will now see a list of all user mailboxes (Fig. 1.).

    525-1-Exchange Admin Center on-prem
    Fig. 1. User mailboxes shown in the Exchange admin center.

    1. To export this list to a CSV file, click the (ellipsis) button and from the drop-down menu choose Export data to a CSV file (Fig. 2.).

    525 - 2 - Export mailboxes to CSV
    Fig. 2. Exporting mailboxes to a CSV file.

    1. In the window that opens, tick checkboxes next to the user data you want to export (Fig. 3.). If you're going to use the CSV file in CodeTwo migration software, you need to export at least the user’s first and last name, email address and the display name.

    525-3-choose properties to export
    Fig. 3. Selecting the user data to be exported.

    1. Click the export button. The file will be downloaded to your local drive.

    Exchange Online (Office 365)

    1. Sign in directly to the Exchange admin center or follow the instructions in this Microsoft article.
    2. Go to Recipients > Mailboxes (Fig. 4., item A).

    Exporting user mailboxes from the Exchange admin center.
    Fig. 4. Exporting user mailboxes from the Exchange admin center.

    1. Use the filter drop-down menu and the search box to display the mailboxes you want added to the CSV file (Fig. 4., item B). Only mailboxes that are displayed will be included in the CSV file.
    2. Click the Export button (Fig. 4., item C). The CSV file should start downloading immediately.

    In some situations, you might need to export only selected mailboxes to a CSV file. While the UI-based method doesn’t offer a good way to limit the exported data, you can use sorting and filters available for CSV files (if you open your file in e.g. Microsoft Excel) and copy chosen records to another CSV file.

    See also:

    Was this information useful?