How to export a list of mailboxes to a CSV file
Problem:
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.
Solution:
There are two ways to prepare a CSV file listing all the mailboxes residing on an Exchange on-premises or Exchange Online server:
- by using Exchange cmdlets
- by using the Exchange admin center (available for Exchange 2019/2016/2013 and Exchange Online)
Tip
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
- Start Exchange Management Shell (on-premises Exchange) or connect to the Exchange server remotely (Office 365).
- To get the list of all mailboxes hosted on your Exchange server, execute the following cmdlet:
$mailboxes = Get-Mailbox -resultSize unlimited
- 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
Log in to the Exchange admin center as discussed in the instructions for Exchange Server 2019 and 2016 and Exchange Server 2013.
- Choose recipients from the feature panel. You will now see a list of all user mailboxes (Fig. 1.).
Fig. 1. User mailboxes shown in the Exchange admin center.
- 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.).
Fig. 2. Exporting mailboxes to a CSV file.
- 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.
Fig. 3. Selecting the user data to be exported.
- Click the export button. The file will be downloaded to your local drive.
Exchange Online (Office 365)
- Sign in directly to the Exchange admin center or follow the instructions in this Microsoft article.
- Go to Recipients > Mailboxes (Fig. 4., item A).
Fig. 4. Exporting user mailboxes from the Exchange admin center.
- 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.
- 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:
Related products: | CodeTwo Exchange Migration, CodeTwo Office 365 Migration |
Categories: | How-To |
Last modified: | April 7, 2023 |
Created: | March 3, 2016 |
ID: | 525 |