How to find online archive mailbox size

I was looking for a way to get the size of our online archive mailboxes, but our primary mailboxes are on prem in a hybrid configuration. Most of the powershell scripts I found online where for one or the other because your powershell session has to be connected to an exchange server to pull the data.

I still haven’t found a way to be connected to both, so i I created two small scripts to get me the information.

First you need to connect to your local exchange server, either RDP to the box or use remote powershell to connect Then run this command to get a list of users with archive enabled.

 Get-Mailbox | where {$_.archivestatus -eq 'active'} |select alias -expandproperty alias |out-file c:temparchive-users.txt 

Now you’ll need the text file as an input to run against a powershell session that is connected to o365.


Import-Module msonline
$Cred = Get-Credential
Connect-MsolService -cred $Cred
Get-Command ?Module msonline
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session
Get-Content C:Temparchive-users.txt | ForEach-Object { Get-MailboxStatistics -id $_ -archive |select displayname,totalitemsize,itemcount}

This will display the name of the archive, total size, and item count in your powershell window. If you want you can export-csv and work with the data in excel.

If anyone knows a way to clean this code up or make it into a single script. Please let me know in the comments below.

Photo by ell brown

One thought on “How to find online archive mailbox size

  1. Use this command to retrieve only online archive mailbox sizes and it mailbox is residing in on-premise exchange server.

    Get-MailUser xyz@abc.com | Get-MailboxStatistics -Archive | select totalitemsize

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.