You want to create mailboxes in Exchange Online and use Office 365. Before you can…
Export a list of mailboxes to CSV in Exchange
You need to export a list of mailboxes to a CSV file in Exchange Server. Such a list can be important. For example, there is a mailbox migration coming. With that list, you can get more information about the mailboxes of the users. In this article, you will learn how to do it through PowerShell.
Export a list of mailboxes to CSV through PowerShell
The information you need to export is display name, user account and email address. Before you start the export to a CSV file, you can make use of the Out-GridView cmdlet. This cmdlet will give you the results without exporting. I recommend doing that first. Let’s see it in action.
Run Exchange Management Shell as administrator. Make use of the command Resultsize 10. The output will list only 10 users. It will generate faster without a load on the server.
1 2 |
[PS] C:\>Get-Mailbox -ResultSize 10 | Select-Object DisplayName, SamAccountName, PrimarySmtpAddress | Out-GridView WARNING: There are more results available than are currently displayed. To view them, increase the value for the ResultSize parameter. |
You can sort the output on email address. Run the following command.
1 2 |
[PS] C:\>Get-Mailbox -ResultSize 10 | Select-Object DisplayName, SamAccountName, PrimarySmtpAddress | Sort-Object PrimarySmtpAddress | Out-GridView WARNING: There are more results available than are currently displayed. To view them, increase the value for the ResultSize parameter. |
Now that you can confirm that the information is correct. You can change the command to Resultsize Unlimited. Run the following command.
1 |
[PS] C:\>Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName, SamAccountName, PrimarySmtpAddress | Sort-Object PrimarySmtpAddress | Out-GridView |
If all is looking great, let’s export the information to a CSV file. First make sure that you have a folder created on your C: drive with the name output. The path in Windows Explorer should show as C:\output\.
1 |
[PS] C:\>Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName, SamAccountName, PrimarySmtpAddress | Sort-Object PrimarySmtpAddress | Export-CSV c:\output\display_sam_smtp.csv -NoTypeInformation -Encoding UTF8 |
CSV file export is complete.
Result exported list of mailboxes to CSV
Go to the path c:\output\display_sam_smtp.csv.
Open the CSV file with your favorite application. I opened the CSV file with Microsoft Excel.
That’s it. Export a list of mailboxes to CSV in Exchange Server completed.
Conclusion
In this article, you learned how to export a list of mailboxes to CSV in Exchange. Use the Out-GridView cmdlet before exporting it to a CSV file. Did you use the PowerShell command to export a list of mailboxes to CSV in Exchange? If you enjoyed this article, you may also like Disable external access to ECP Exchange 2016. Don’t forget to follow us and share this article.
Thanks a lot, it’s so useful for me
Thanks again.