Just How Much Mail Do You Have in Office 365?
Heya happy Mondy everyone, CDub here! Obviously more and more business’ are moving their on-premises Exchange environments to Office 365 and operate all in the ‘cloud.’ While some run hybrid – meaning that they’ve still run an on-premises Exchange infrastructure in addition to their Office 365 environment.
In my environment I still run Exchange on-premises as well as Office 365 as well, unfortunately Microsoft does not make it even possible to determine just how much data you have in Office 365 through the the Admin Portal. What ever shall we do!?! POWERSHELL!!
The MSOnline PowerShell Module contains the necessary cmdlet’s to get connected to your Office365 Subscription.
Set-ExecutionPolicy RemoteSigned Install-Module -Name MSOnline -AllowClobber -Force Import-Module MSOnline mkdir c:Temp $credential = Get-Credential Connect-MsolService -Credential $credential $exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection Import-PSSession $exchangeSession -DisableNameChecking -AllowClobber Get-Mailbox | Format-List
Format-List gives us every mailbox with all of their properties so we know exactly what’s available for our use.
Now we can determine the actual mailbox sizes!
Set-ExecutionPolicy RemoteSigned Install-Module -Name MSOnline -AllowClobber -Force Install-Module -Name Azure -AllowClobber -Force Install-Module -Name AzureAD -AllowClobber -Force Import-Module MSOnline mkdir c:Temp $credential = Get-Credential Connect-MsolService -Credential $credential $exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection Import-PSSession $exchangeSession -DisableNameChecking -AllowClobber $Output = Get-Mailbox | Get-MailboxStatistics | Select-Object displayname,MailboxTypeDetail,ItemCount,totalitemsize $Output | FT $Output | Export-Csv -Path C:TempReport.csv
Run the script. You’ll be prompted for credentials and required to logon. In my testing I used an Organizational Admin Account however. If a user has yet to login to their mailbox, this is useful information and you will notice that in the yellow text below. This is a good way to locate the provisioned mailboxes that have yet to be used.
I’m a huge fan of exporting my PowerShell reportsĀ into a CSV Document for offline analysis – You will notice this is done with the Export-CSV c:TempReport.CSV – Below is my sample output!
PowerShell is an extremely useful tool that every IT Administrator should be using daily!
Script seems to stop at 1000 mailboxes. Anything I can do to get past that?
I’ve not seen this issue and being honest I didn’t test it at that number of mailboxes. I’m wondering if there’s some limit on the amount of results returned?