Microsoft Exchange team releases Exchange Server Security Updates (SUs) when vulnerabilities are discovered. You don't…
Get mailbox size of all users in Exchange with PowerShell
We want to get the mailbox size of all users in Exchange with PowerShell. Why do we need to list the mailbox size for all users? For example, you want to migrate the users to a new Exchange Server. Before doing that, find all the users’ mailbox size in Exchange. What if you need more information regarding the mailbox. What kind of information do you need in particular? The script that we are going to use in this article will gather 22 types of information per mailbox.
Table of contents
Information mailbox size of all users PowerShell script
The script will run and find all users with a mailbox including the size. It does have more than one option. The one that we are interested in is to export a list to CSV. The following information per mailbox will be gathered in the CSV file:
- Display Name
- Alias
- SamAccountName
- RecipientType
- Recipient OU
- Primary SMTP address
- Email Addresses
- Database
- ServerName
- TotalItemSize
- ItemCount
- DeletedItemCount
- TotalDeletedItemSize
- ProhibitSendReceiveQuota-In-MB
- UseDatabaseQuotaDefaults
- LastLogonTime
- ArchiveName
- ArchiveStatus
- ArchiveState
- ArchiveQuota
- ArchiveTotalItemSize
- ArchiveTotalItemCount
Get mailbox size of all users with PowerShell script
Let’s configure the script and see it in action. Download the following PowerShell script from here (Microsoft) or here (direct link). Save it on your Exchange Server in the following path: C:\scripts\. This script is made by MVP Satheshwaran Manoharan.
Run Exchange Management Shell as administrator. Run the following commands to change the directory path and start the script. The Mailbox Size Report script will be displayed.
[PS] C:\>cd c:\scripts
[PS] C:\scripts>.\MailboxSizeReport.ps1
Mailbox Size Report
----------------------------
1.Display in Exchange Management Shell
2.Export to CSV File
3.Export to CSV File (Specific to Database)
4.Enter the Mailbox Name with Wild Card (Export)
5.Enter the Mailbox Name with Wild Card (Display)
6.Export to CSV File (OFFICE 365)
7.Enter the Mailbox Name with Wild Card (Export) (OFFICE 365)
Choose The Task:
The script got 7 options. The one that we are looking for is option 2. Export to CSV File.
Insert 2 and press Enter.
[PS] C:\scripts>.\MailboxSizeReport.ps1
Mailbox Size Report
----------------------------
1.Display in Exchange Management Shell
2.Export to CSV File
3.Export to CSV File (Specific to Database)
4.Enter the Mailbox Name with Wild Card (Export)
5.Enter the Mailbox Name with Wild Card (Display)
6.Export to CSV File (OFFICE 365)
7.Enter the Mailbox Name with Wild Card (Export) (OFFICE 365)
Choose The Task: 2
Enter the Path of CSV file (Eg. C:\Report.csv):
The Mailbox Size Report PowerShell script will ask for a path. The export of the CSV file will get exported to that path.
Insert the following path: C:\scripts\report.csv and press Enter.
[PS] C:\scripts>.\MailboxSizeReport.ps1
Mailbox Size Report
----------------------------
1.Display in Exchange Management Shell
2.Export to CSV File
3.Export to CSV File (Specific to Database)
4.Enter the Mailbox Name with Wild Card (Export)
5.Enter the Mailbox Name with Wild Card (Display)
6.Export to CSV File (OFFICE 365)
7.Enter the Mailbox Name with Wild Card (Export) (OFFICE 365)
Choose The Task: 2
Enter the Path of CSV file (Eg. C:\Report.csv): C:\scripts\report.csv
The Mailbox Size Report PowerShell script starts scanning the mailboxes in the organization. This can take some time. When done, a list is created and exported in a CSV file. You can exit the script.
Result mailbox size of all users in Exchange
Let’s have a look if the script made the export successful by going to the following path: C:\scripts\. You should see the report.csv file.
Open report.csv with your favorite application, for example with Microsoft Excel. If you don’t need all the information, you can remove those columns. You can sort the file by Display Name, TotalItemSize or by any other type. Tweak the information to your needs.
Conclusion
In this article, you did learn how to get the mailbox size of all users in Exchange with PowerShell. It’s a great script to list the mailbox size for all users in the organization. You should use it more often to get the mailbox size and extra information. If you enjoyed this article, you may also like Not digitally signed error when running PowerShell script. Don’t forget to follow us.
x\thank you a lot .
can we schedule it in task scheduler with attributes 2 of exporting and constant shared location ?
hi
is possible add if account in active directory is disable or no?
thz
kindly share the script with me
Hello, Ali.
Thank you for this script.
I’d like to understand why did you use the BigFunnelMessageCount instead of the ItemCount when counting archive messages?