Link to home
Start Free TrialLog in
Avatar of Isaias Perez
Isaias PerezFlag for United States of America

asked on

Exchange- Office 365 mailbox size/statistics

We have a hybrid environment at our location. What is the best way to get statistics on ALL Licensed E1 users mailbox size? ONLY E1 Licensed users. My goal is to convert all E1 licenses to F1 but since F1 has a size limit of 2GB i would like to check mailbox usage first of all E1 users prior to changing licenses. Can anyone help please as this is urgent. Is this best done via the o365 GUI or power-shell?

I have tried the following to gather information or head in the right direction

Gets all E1 Users but does not show me mailbox size

get-MSOLUser -All | where {$_.isLicensed -eq "TRUE" -and $_.Licenses.AccountSKUID -eq "Contoso:STANDARDPACK"} | Out-GridView

This script would work but i would like to import-csv the users list of users under 2GB of mailbox size instead of mass deploying it all.

https://blogs.technet.microsoft.com/cloudpfe/2014/01/30/how-to-change-office-365-licenses-in-bulk-respecting-the-license-options/ 

Ive thought about changing this line to accomplish that:

$users = Import-Csv -Path C:\users.csv     Rather than>         #Get-MsolUser -MaxResults 5000 | Where-Object { $_.isLicensed -eq "TRUE" }

This way i can import a list of all E1 Licensed Users with a mailbox under 2GB.

Can anyone help please.
Avatar of Rajkumar Duraisamy
Rajkumar Duraisamy
Flag of India image

To check the mailboxsize..

Connect Exchange Online PowerShell & run the below command

Get-Mailbox -resultsize unlimited | get-mailboxstatitics | export-csv c:\temp\mailboxstatistics.csv -notypeinformation.

If you want to check the mailbox statistics only for the licensed users..

Import-Csv -Path C:\users.csv |foreach { get-mailboxstatitics $_.Alias } | export-csv c:\temp\mailboxstatistics.csv -notypeinformation.

filter the output ofTotalItemSize colum greater than 2 GB.
Avatar of Isaias Perez

ASKER

This worked great Rjkumar thank you. The issue is that the get-mailboxstatitics cmdlet will give me the mailbox size but then for some reason they dont give a unique identifier like the .smtpaddress or .samAccountname belonging to that object. I only see the display name and i need the corresponding unique identifier so i can then take this information and feed it to another script listed here. Do you have any suggetions?

https://blogs.technet.microsoft.com/cloudpfe/2014/01/30/how-to-change-office-365-licenses-in-bulk-respecting-the-license-options/
Please try this.. You can change the input based your requirement.. and also can add as many parameters in output

$Input = get-mailbox -resultsize unlimited | Select Alias

$Input | Foreach-Object {
    $mbx = Get-Mailbox $_.Alias
    $mbxstat = Get-MailboxStatistics $_.Alias

    New-Object -TypeName PSObject -Property @{
        Alias = $mbx.Alias
        TotalItemSize = $mbxstat.totalitemsize
        TotalItemSizeInMB = $mbxstat | Select {$_.TotalItemSize.Value.ToMB()}
        PrimarySMTPAddress = $mbx.primarysmtpaddress
 
    }
} | Export-csv C:\Temp\MailboxStatistics.csv -NotypeInformation
We are getting so close. Thank you very  much. Last thing i would like to ask is can we change the first line of the script to accept import-csv users? Does it need specific headers? I have a list of all E1 licensed users that i want to speficially find their mailbox size. Is this possible?

$Input = import-csv c:\e1licensedusers    |Select Alias         Instead of >>>get-mailbox -resultsize unlimited | Select Alias

I would assume one of the headers would be Alias ?
Import-csv C:\Temp\Input.csv | Foreach-Object {
    $mbx = Get-Mailbox $_.Alias
    $mbxstat = Get-MailboxStatistics $_.Alias

    New-Object -TypeName PSObject -Property @{
        Alias = $mbx.Alias
        TotalItemSize = $mbxstat.totalitemsize
        TotalItemSizeInMB = $mbxstat | Select {$_.TotalItemSize.Value.ToMB()}
        PrimarySMTPAddress = $mbx.primarysmtpaddress
 
    }
} | Export-csv C:\Temp\MailboxStatistics.csv -NotypeInformation

Ensure the input file has a header as Alias and users aliases down to it.
How about using the UserPrincipalName instead?

Import-csv C:\Temp\Input.csv | Foreach-Object {
    $mbx = Get-Mailbox $_.UserPrincipalName
    $mbxstat = Get-MailboxStatistics $_.Alias

    New-Object -TypeName PSObject -Property @{
        Alias = $mbx.Alias
        TotalItemSize = $mbxstat.totalitemsize
        TotalItemSizeInMB = $mbxstat | Select {$_.TotalItemSize.Value.ToMB()}
        PrimarySMTPAddress = $mbx.primarysmtpaddress
 
    }
} | Export-csv C:\Temp\MailboxStatistics.csv -NotypeInformation
upn.png
ASKER CERTIFIED SOLUTION
Avatar of Rajkumar Duraisamy
Rajkumar Duraisamy
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much!!
I did get the following error message.
error-1.png
Nevermind I named the csv file incorrectly to iput.csv. Was pulling no data. Arghhh
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes all is set. Thank you.