Get Mailbox Size for List of Users from CSV

Vinod Shreenivas Poojary 1 Reputation point

Hello Team,

i am not a Powershell expert. Looking for some assistance in this forum.

Does anyone has any handy script which would take the CSV file as input Let us just say User count of 50 in a CSV file

and then provide me the export of their mailbox size details with the below information

  1. UserPrincipalName
  2. Mailbox Size in GB
  3. MailboxItemCount


Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,307 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,428 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,951 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Kael Yao-MSFT 37,586 Reputation points Microsoft Vendor

    Hi @Vinod Shreenivas Poojary

    Please kindly note that our forum doesn't support scripting requests.
    If you need some suggestions for your script, I would recommend adding the windows-server-powershell to the scripting question in order to get better support.
    Thanks for your understanding.

    Would the following script work for you?

    $report = @()  
    $Users = Import-CSV c:\temp\inbox.csv  
    foreach($User in $Users)  
    $x = Get-Mailbox $User.PrimarySMTPAddress  
    $y = Get-MailboxStatistics $User.PrimarySMTPAddress  
    $report += New-Object PSObject -Property $([ordered]@{  
    "UserPrincipalName" = $x.UserPrincipalName  
    "MailboxSize" = $y.TotalItemSize  
    "MailboxItemCount" = $y.ItemCount  
    "MailboxUsageLocation" =$x.Usagelocation  
    $report | export-csv c:\temp\result.csv  

    In my input.csv file I am using PrimarySMTPAddress as the filter for mailbox identity.
    You may modify this part if you would like to use other attributes.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.