Get Mailbox Size for List of Users from CSV

Vinod Shreenivas Poojary 1 Reputation point
2022-04-13T08:33:33.727+00:00

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

4.MailboxUsageLocation

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Exchange Exchange Server Management
Exchange Hybrid management
{count} votes

1 answer

Sort by: Most helpful
  1. Kael Yao 37,746 Reputation points Moderator
    2022-04-14T05:52:03.44+00:00

    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.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.