We like to migrate Exchange mailboxes with a CSV file to another database. It will…
Export a list of mailboxes to text in Exchange
You need to export a list of mailboxes to a text 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 users’ mailboxes. In this article, you will learn how to export a list of mailboxes to text file in Exchange with PowerShell.
Export a list of mailboxes to text with PowerShell
The information you need to export is:
- DisplayName
- SamAccountName
- PrimarySMTPAddress
Before you start the export to a text file, you can use 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. Use the Get-Mailbox cmdlet, including the ResultSize parameter. The output will list only 10 users. Therefore, it will generate faster without a load on the server.
[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 by email address.
[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 and add Resultsize Unlimited to it.
[PS] C:\>Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName, SamAccountName, PrimarySmtpAddress | Sort-Object PrimarySmtpAddress | Out-GridView
If everything looks great, export the information to text file. First, ensure a folder is created on the (C:) drive with the name output. The path in Windows Explorer should show as C:\output\.
[PS] C:\>Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName, SamAccountName, PrimarySmtpAddress | Sort-Object PrimarySmtpAddress | Out-File "C:\output\display_sam_smtp.txt" -Encoding UTF8 ; (Get-Content "C:\output\display_sam_smtp.txt" | Select-Object -Skip 1) | Set-Content "C:\output\display_sam_smtp.txt"
The text file export is complete.
Result exported list of mailboxes to text file
Go to the path c:\output\display_sam_smtp.txt
Open the text file with your favorite application. For example, with Notepad or Notepad++.
The text file with all the information looks great.
Note: To export a mailbox size report, read the article Get mailbox size of all users in Exchange with PowerShell.
Conclusion
You learned how to export a list of mailboxes to text in Exchange. Use the Out-GridView cmdlet before exporting it to a text file. Did you use the PowerShell command to export a list of mailboxes to text in Exchange?
Did you enjoy this article? You may also like Export a list of mailboxes to CSV in Exchange. Don’t forget to follow us and share this article.
This Post Has 0 Comments