Script Dumpster: List all email addresses and Mailbox Size – OnPrem & O365


I’ve optimized the script to now only query each mailbox once and have increased the speed in this customer’s environment for On-premise from 1 minute 49 seconds to 26 seconds.
The Office 365 code was optimized similarly and went down from 22 minutes 14 seconds to 7 minutes 21 seconds.

The output of the optimized script is identical to the original one.


As the title suggest, I had a customer asking for a list of all email addresses within the company and the accompanying mailbox sizes.

Now this customer has a hybrid Exchange 2013/Office 365 environment, which provides some challenges. Certain On-prem cmdlets provide different output compared to their Office 365 counterparts.

Long story short, currently I have 2 scripts that will simply provide me with all of the required data.


Both pieces of code already assume that you’re connected to the Exchange/Office 365 environment with all the required permissions and cmdlets available.

On-Premise code

Office 365 code




It never hurts to Get-Help

Leave a Reply

Your email address will not be published. Required fields are marked *