Home » Exchange Server » Reporting Mailbox Folder Sizes with PowerShell

Reporting Mailbox Folder Sizes with PowerShell

Rebecca asks:

I am trying to find a command that will return the user and total item count for the inbox only. Can this be done?

The solution to Rebecca’s scenario is in the Get-MailboxFolderStatistics cmdlet. This cmdlet can be used to report on some or all of the individual folders within a mailbox, returning such information as their size and item count.

For example:

If you ran that command against a mailbox in your organization you will see a lot of information returned. You may wish to return just a few of the more interesting bits of information instead, for example:

Similarly you may wish to only look at specific folders and subfolders, which you can achieve using the -FolderScope parameter. For example:

So getting back to Rebecca’s question, what if we just want to know the total size of the inbox? The command above returns two values, one for the inbox and one for the subfolder “Old mail”. In a report of “Inbox sizes” we would want the total of both.

Fortunately one of the values returned by Get-MailboxFolderStatistics is for the size of the folder and subfolders.

Also, we just want the inbox itself in our report, not every subfolder listed individually.

Finally, if I was interested in a report of the inbox sizes for all mailboxes in the organizations, I would probably whip up a quick script like this.

Saving that as Get-InboxReport.ps1 I can then run it in the Exchange Management Shell.

I could even output it to CSV file for further analysis.

exchange-powershell-inbox-size-report

The script above is just a few lines with no error handling, parameters, or other useful elements that you might find in a script, but it is just to give you an idea of what is possible with Get-MailboxFolderStatistics.

I hope that answers your question Rebecca.

Paul is a Microsoft MVP for Office Servers and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul is a co-author of Office 365 for IT Pros and several other books, and is also a Pluralsight author.
Category: Exchange Server

69 comments

  1. lennys says:

    how about to combine with msg tracking log with certain folder like ‘Outbox’ or ‘Sent Items’. normally i use as per Exchangeserverpro notes :

    Get-MessageTrackingLog -Start “7/10/2012 08:00:00” -End “7/10/2012 18:00:00″ | Select-Object eventid,sender,timestamp,@{Name=”Recipients”;Expression={$_.recipients}},@{Name=”RecipientStatus”;Expression={$_.recipientstatus}},messagesubject -ResultSize unlimited | Export-CSV c:scriptslog6.csv

    AND

    $msgs = Get-TransportServer | Get-MessageTrackingLog -Sender Tom@exchangeserverpro.net -Recipients Alan.Reid@exchangeserverpro.net | Select-Object eventid,sender,timestamp,@{Name=”Recipients”;Expression={$_.recipients}},@{Name=”RecipientStatus”;Expression={$_.recipientstatus}},messagesubject | export-csv c:scriptslog10.csv

    is it possible to combine with specific folders?

    tq

      • lennys says:

        Hi Paul,
        my apology on my question is quite not clear. What im trying to get is a command which we could able to see the total size in Inbox folder (or any folder), as well as list of email resides in the Inbox folder with certain date specified.

        Hopes this clear to you. Tx in advance for any info you may provide.

  2. Joe says:

    Hi Paul,

    Excellent post. What command should I substitute on your Inbox script for Sent items?

    I want to tell our email users to archive their Sent items, but I want to find out the size of their sent items first.

    Thanks,
    Joe

  3. Ty says:

    Hi Paul, what if I want to see only the root folders under the mailbox? I have a user who has a great amount of subfolders including old System Cleanup folders from Exchange 2003 that show subfolders with the same names as the current root folders and subfolders. I’m worried that when I send the user this solid list that doesn’t show which folders are root folders, they will be confused.

    Thanks!

    Ty

  4. Ramanathan says:

    I have list of users and need to find out whether they have mail items that are older than 6 months in exchange 2010.

  5. Mohammad Ali says:

    Hi Paul,

    I ran the script and in the output file, for few users am not getting item counts instead of getting “BLANK” even though they are visible in GAL.

    I checked the object and every thing seems to be good.

  6. Aasmir says:

    Hi Paul,

    another great TIP, I am trying to add permissions as well. I mean I want to see

    Name, FolderPath, Delegate, AccessRights.

    any suggestion how to combine them ?

    Many Thanks

  7. Anand says:

    Paul,

    I want information such as Mailboxes deleted per Month, Number of Public Folders Deleted per month with size, Public Folders Converted to Mailbox per month. Can you help me out in this?

    I am able to retrieve information about addition of mailbox/PF, but deletion seems to be a tough one for me.

    Thanks in Advance 🙂

  8. Anand says:

    Abdul,

    Yes thats Possible!! Use the below command–

    Get-TransportServer | Get-MessaqgeTrackingLog -Sender “SenderName” -EventtId Receive -Start “12/30/2010 8:00:00 AM” -End “12/31/2010 5:00:00 PM”

    • Abdul Wajid says:

      Dear Anand,

      Good Day,

      Thank you very much for the answer. I tried but it didn’t give any output. My actual requirement is as follows:

      I want to get the message count for received items for a exchange mailbox, that is the number of emails received by a user in a date range.

      Thank You

      Regards

  9. Anand says:

    Abdul,

    What this Command will do, let me tell you–
    This will query the transport logs for the particular recipients. But this purely depends upon the retention period of the transport logs.
    If the logs are just 15 days or 30 days old, and if you query for an email that has been sent 3 months back, it will not give you the result.

    The start time should be within the range of retention.
    Try the below command by giving any recent date/time.. it’ll give you output.
    Get-TransportServer | Get-MessaqgeTrackingLog -Recipients “Name” -EventtId Receive -Start “12/30/2010 8:00:00 AM” -End “12/31/2010 5:00:00 PM”

  10. Abdul Wajid says:

    Dear Anand,

    I get your point. It is showing the results but it is not serving my purpose. Any other way to get the item counts in the mailbox and sort them with time stamp or something so it might help us. Just need to get the number of items received in 2013. There is a time stamp on the mail items and we can sort them out in outlook. There maybe a way of getting this information.

    Thanks for your help

    Regards
    Abdul Wajid

  11. Blue Devil says:

    Excellent post! Is there a way to combine the report? On a single CSV I want to show Inbox Size, Deleted Item Size, Sent Items Size and Calendar Items Size? Is that possible? if it how do it do it? Thank you again for this great post.

  12. Ruixia Zhang says:

    Hi Paul,
    I have a question to ask,the description is as followed:
    First,I new a mailbox,then enable archive box,but when I excute
    get-mailboxstatistics ccc -archive
    get the result: ItemCount :1
    Meanwhile,I login this user by owa only to find {In-Place Archive – ccc} is empty.So, How can I view this user’archive directory in my computer ?

  13. jason says:

    Hi Paul,

    in your last steps above, – report of the inbox sizes for all mailboxes in the organizations – any way to add unread items also?

    Thank you.

    • The example uses the cmdlet Get-MailboxFolderStatistics . I don’t see a parameter for that cmdlet that will reveal the info on unread items. You would likely be able to do it using Exchange Web Services (EWS) if you hunt around for some sample code.

  14. abhishek says:

    Can We get count of messages of user in inbox from specific date range through Get-MailboxStatistics & Get-MailboxFolderStatistics.

  15. mike says:

    Great writeup!
    I need to gather some folder stats for a certain list of people. I have tried various times using import-csv and get-content, but cannot figure out how to make it work. If I have a certain list of users and need to export stats (name, foldersize, itemsinfolder) to a csv file, how do I constuct the command?

    Obviously I can still trying to master powershell, so any help is appreicated. Thanks!

  16. mike says:

    sorry, example:
    Get-MailboxFolderStatistics user1 -FolderScope Inbox | Where {$_.FolderPath -eq “/Inbox”} | Select Name,FolderandSubFolderSize,ItemsinFolderandSubfolders | export-csv c:file.csv

    If I want to sub a csv file with a list of users in place of user1

  17. Kshreek says:

    We need a script to examine each mailbox to determine its size, the number of items and the items in the mailbox that exceed 20MB. . This script needs to be able to be run by group, and by city and by DB.

  18. TRAN XUAN QUANG says:

    I get mailbox contact folder, the contact folder has alot of items, I want to delete all of contact. Please help me to resolve the issue.
    thanks

  19. TRAN XUAN QUANG says:

    I alos used the command below to delete all contact in mailbox, but it is not success.

    search-mailbox -identity USERNAME -searchquery kind:contacts -deletecontent

    Please help me to delete all contact on user mailbox.

    THanks

  20. Mike says:

    Hi Paul,

    I realise that this is an old thread, so I’m hoping that you’re still checking it. I have modified your script to try to export a list of users, filtered by their SyncIssues folders. I’m not quite sure where my mistake is, however my csv file is blank except for the headings of Display Name, Size (MB), Inbox Items. The command runs without any errors, and I know for sure that SyncIssues folders do exist as I have tested.

    When I manually run the command below I get everything I need, for that one user. Would you please take a look at the script and tell me where I’m messing this up?

    Command that works:

    get-mailboxfolderstatistics “username” -folderscope syncissues | sort-object FolderSize -descending | FT foldertype, FolderSize, ItemsInFolder | export-csv “c:usersusernamedesktopsizes.csv”

    Modified Script that doesn’t work as expected:

    $mailboxes = (Get-Mailbox -ResultSize Unlimited)
    $report = @()
    foreach ($mailbox in $mailboxes)
    {
    $inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope SyncIssues
    $mbObj = New-Object PSObject
    $mbObj | Add-Member -MemberType NoteProperty -Name “Display Name” -Value $mailbox.FolderType
    $mbObj | Add-Member -MemberType NoteProperty -Name “Size (Mb)” -Value $inboxstats.FolderSize
    $mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Items” -Value $inboxstats.ItemsinFolder
    $report += $mbObj
    }
    $report

    • Mike says:

      Hi Paul,

      After some playing around with the code (and finding a forum that helped with the sorting), I have found a solution that appears to work. Have a good one.

      #This script queries the Exchange domain, filtering by mailboxes that contains a SyncIssues folder, and then displays them in descending order based on total size including subfolders
      #
      $mailboxes = @(Get-Mailbox -ResultSize Unlimited)
      $report = @()
      foreach ($mailbox in $mailboxes)
      {
      $inboxstats = Get-MailboxFolderStatistics $mailbox | Where {$_.FolderPath -eq “/Sync Issues”}
      $mbObj = New-Object PSObject
      $mbObj | Add-Member -MemberType NoteProperty -Name “Display Name” -Value $mailbox.DisplayName
      $mbObj | Add-Member -MemberType NoteProperty -Name “Folder Type” -Value $inboxstats.FolderType
      $mbObj | Add-Member -MemberType NoteProperty -Name “Size (Mb)” -Value $inboxstats.FolderandSubFolderSize
      $report += $mbObj
      }
      $report | Sort-Object “Size (Mb)” -descending
      $report

    • One problem with that first attempt is that you’re piping through Format-Table (FT) then trying to pipe to Export-CSV.

      Basically you should only pipe to Format-* cmdlets if you want to display results in your PowerShell console. If you plan to pipe objects to other cmdlets then don’t send to Format-* first.

      I suspect your first attempt would have worked by replacing FT with Select-Object instead.

  21. Andy M says:

    Hi Paul,

    Wonder if you can assist (I am very new to PS) – I am looking to list out each user Deleted Item size and count and found the following that work perfectly for individual user mailboxes

    “Get-MailboxFolderStatistics User.Name -FolderScope DeletedItems | Select Name,FolderSize,ItemsinFolder”

    Is they a way i can amend this command to run against all users mailboxes in a specific DB Store and output the same information

  22. Saeed Mulla says:

    Hi,

    My setup has a live mailbox and an archive mailbox for each user (3000 users).

    I’m doing a exchange analysis report to see a list of all users with live quotas assigned, how much of that quotas is used along with total item count per mailbox as well as the matching archive mailbox also showing quota, used amount and item count in the same csv export.

    I’ve worked out how to do it per mailbox – but that means i have to find and match each user to archive mailbox csv sheet- which for a few users is OK- but for 3000 its a nightmare.

    Example of output i’m looking for:

    Alias | Email address | Live Quota | Live Used | Item count of live mailbox | Archive Quota | Archive Used | item count of archive mailbox

    Can you help?

  23. Graeme says:

    Hi Paul,

    I’m trying to do something that should be easier, return a simple numeric value for the number of items in the inbox of 1 particular mailbox. I want to use this to monitor a journal mailbox that our archiving software (Archive Manager) cleans out as it processes, so that we are alerted if there is a problem with it. This is the closest thing I’ve found, but it’s output doesn’t work for what I had in mind. Can you suggest a way to get the result I need?

  24. vinod says:

    Hi Paul,

    The script is awesome i need a script something like, the foldersize greater than 100 MB, when i write with the help of your script it is showing only one folder which is having highest size,not all folders greater than 100 mb..

  25. Pravar says:

    Hi Paul,

    Thanks. You saved my day. I have slightly changed the script to suit my requirement. However the output shows blank for the users who have multiple folders directly under Inbox. Am I missing something here and can I send this report by html e-mail? Thanks once again.

    $mailboxes = @(get-distributiongroupmember -Identity “Test” | get-mailbox)
    $report = @()

    foreach ($mailbox in $mailboxes)
    {
    $inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope Inbox

    $mbObj = New-Object PSObject
    $mbObj | Add-Member -MemberType NoteProperty -Name “Display Name” -Value $mailbox.DisplayName
    $mbObj | Add-Member -MemberType NoteProperty -Name “Folder Name” -Value $inboxstats.Name
    $mbObj | Add-Member -MemberType NoteProperty -Name “Folder Location” -Value $inboxstats.FolderPath
    $mbObj | Add-Member -MemberType NoteProperty -Name “Items in Folder” -Value
    $inboxstats.ItemsinFolder
    $report += $mbObj
    }

    $report

  26. Simon Hopkin says:

    Hi Paul,

    How would you modify your script to include only Inbox & Sent Items (Folder Size & Number of Items) in a single CSV.

    The scripts works great for all mailboxes pulling Inbox stats, I would like to include Sent Items in the same output.

  27. Tony G says:

    Hi Paul,

    I’ve been reading this page and it has really helped. I manage a network of 75 users and management wants Exchange reports. I’ve tested the script you have above for inbox items and size and it works great. I need to also include the Sent and Deleted Items folders in the same report. I tried copying the lines and just changing the folder names but received multiple errors.

    Here is a small snippet of what I’ve tried. Your assistance is greatly appreciated. Can you help?

    $report

    $mailboxes = @(Get-Mailbox -ResultSize Unlimited)
    $report = @()

    foreach ($mailbox in $mailboxes)
    {
    $inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope Inbox | Where {$_.FolderPath -eq “/Inbox” or “/Sent Items” or “/Deleted Items”}

    $mbObj = New-Object PSObject
    $mbObj | Add-Member -MemberType NoteProperty -Name “Display Name” -Value $mailbox.DisplayName
    $mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB()
    $mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Items” -Value $inboxstats.ItemsinFolderandSubfolders
    $mbObj | Add-Member -MemberType NoteProperty -Name “Deleted Items Size (Mb)” -Value $Deletedstats.FolderandSubFolderSize.ToMB()
    $mbObj | Add-Member -MemberType NoteProperty -Name “Deleted Items” -Value $Deletedstats.ItemsinFolderandSubfolders
    $mbObj | Add-Member -MemberType NoteProperty -Name “Sent Items Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB()
    $mbObj | Add-Member -MemberType NoteProperty -Name “Sent Items” -Value $SentItemsstats.ItemsinFolderandSubfolders
    $report += $mbObj

  28. Tony G says:

    Hi Paul,

    Thanks for replying so quick. Here is the output from PowerShell. It’s from a 2008 r2 server running Exchange 2007.

    Get-UMIPGateway | ForEach {If($_.OutCallsAllowed -Eq $False){ “Gateway Name = ” +$_.Name;ForEach ($HuntGroup In $_.Huntgroups){“Huntgroups ” + $Huntgroup}}}

    [PS] C:Windowssystem32>cd
    [PS] C:\>$mailboxes = @(Get-Mailbox -ResultSize Unlimited)
    [PS] C:\>$report = @()
    [PS] C:\>
    [PS] C:\>foreach ($mailbox in $mailboxes)
    >> {
    >> $inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope Inbox | Where {$_.FolderPath -eq “/Inbox” or “/Sent Items” or “/Deleted Items”}
    >>
    Unexpected token ‘or’ in expression or statement.
    At line:3 char:113
    + $inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope Inbox | Where {$_.FolderPath -eq “/Inbox” or <<< $mbObj = New-Object PSObject
    [PS] C:\> $mbObj | Add-Member -MemberType NoteProperty -Name “Display Name” -Value $mailbox.DisplayName
    [PS] C:\> $mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB()
    You cannot call a method on a null-valued expression.
    At line:1 char:120
    + $mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB <<< $mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Items” -Value $inboxstats.ItemsinFolderandSubfolders
    [PS] C:\> $mbObj | Add-Member -MemberType NoteProperty -Name “Deleted Items Size (Mb)” -Value $Deletedstats.FolderandSubFolderSize.ToMB()
    You cannot call a method on a null-valued expression.
    At line:1 char:130
    + $mbObj | Add-Member -MemberType NoteProperty -Name “Deleted Items Size (Mb)” -Value $Deletedstats.FolderandSubFolderSize.ToMB <<< $mbObj | Add-Member -MemberType NoteProperty -Name “Deleted Items” -Value $Deletedstats.ItemsinFolderandSubfolders
    [PS] C:\> $mbObj | Add-Member -MemberType NoteProperty -Name “Sent Items Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB()
    You cannot call a method on a null-valued expression.
    At line:1 char:125
    + $mbObj | Add-Member -MemberType NoteProperty -Name “Sent Items Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB <<< $mbObj | Add-Member -MemberType NoteProperty -Name “Sent Items” -Value $SentItemsstats.ItemsinFolderandSubfolders
    [PS] C:\> $report += $mbObj
    [PS] C:\>}
    Unexpected token ‘}’ in expression or statement.
    At line:1 char:2
    + } <<<
    [PS] C:\>}

    • Unexpected token ‘or’ in expression or statement.
      At line:3 char:113

      That’s the first error, the ‘or’ is unexpected. That error is causing the rest of the errors. Look at that first error, caused by the line of the script that runs right before the error is thrown.

      To give you a hint, you’re not using valid conditional operators.

  29. Robert says:

    Hey Paul,

    Is there a way to pull this kind of information but for all mail after a specific date? We are trying to get the item count and size of any mail that was sent to a user AFTER they were Disabled. There will be a list of several users and each user will have a different Disabled date.

    Thanks!

  30. Laeeq Qazi says:

    Hi Paul,

    Please use
    Export-CSV inboxsizes.csv -NoTypeInformation
    instead of
    Export-CSV inboxsizes.csv
    to skip first unwanted row in output csv file.

    Kind Regards,
    Laeeq Qazi

  31. Scott says:

    Does this work in Exchange Online? I get error messages

    At C:scriptsoutbox.ps1:10 char:5
    + $mbObj | Add-Member -MemberType NoteProperty -Name “Inbox Size (Mb)” -Value …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Cannot process argument transformation on parameter ‘Identity’. Cannot convert value “User” to type “Microsoft.Exchange.Configuration.Tasks.GeneralMailboxOrMailUserIdParameter”. Error: “Cannot convert hashtable to an
    object of the following type: Microsoft.Exchange.Configuration.Tasks.GeneralMailboxOrMailUserIdParameter. Hashtable-to-Object conversion is not supported in restricted language mode or a Data section.”
    + CategoryInfo : InvalidData: (:) [Get-MailboxFolderStatistics], ParameterBindin…mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-MailboxFolderStatistics
    + PSComputerName : outlook.office365.com

    You cannot call a method on a null-valued expression.

  32. Scott says:

    Please ignore my previous post as I figured out the problem. I’m trying to do something similar for the outbox where I just obtain a list of users who have items in the outbox. When I modify this I get a csv of all users and the users who don’t have anything in the outbox appear with a blank. How do I exclude those users and just get the users who have more than 0 items?

  33. Jake says:

    For those looking to report on multiple values, this is for Sent Items, Deleted Items, and Deletions:

    $mailboxes = @(Get-Mailbox -ResultSize Unlimited)
    $report = @()

    foreach ($mailbox in $mailboxes)
    {
    $mbObj = New-Object PSObject
    $mbObj | Add-Member -MemberType NoteProperty -Name “Display Name” -Value $mailbox.DisplayName

    $inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope SentItems | Where {$_.FolderPath -eq “/Sent Items”}
    $mbObj | Add-Member -MemberType NoteProperty -Name “Sent Items Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB()
    $mbObj | Add-Member -MemberType NoteProperty -Name “Sent Items” -Value $inboxstats.ItemsinFolderandSubfolders

    $inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope DeletedItems | Where {$_.FolderPath -eq “/Deleted Items”}

    $mbObj | Add-Member -MemberType NoteProperty -Name “Deleted Item Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB()
    $mbObj | Add-Member -MemberType NoteProperty -Name “Deleted Items” -Value $inboxstats.ItemsinFolderandSubfolders

    $inboxstats = Get-MailboxFolderStatistics $mailbox -FolderScope RecoverableItems | Where {$_.FolderPath -eq “/Deletions”}

    $mbObj | Add-Member -MemberType NoteProperty -Name “Deletions Item Size (Mb)” -Value $inboxstats.FolderandSubFolderSize.ToMB()
    $mbObj | Add-Member -MemberType NoteProperty -Name “Deletions Items” -Value $inboxstats.ItemsinFolderandSubfolders

    $report += $mbObj
    }

    $report | Export-CSV .MailboxSentDeletedDeletions.csv -NoType

    Created this thanks to Paul’s original script. Very nice job as always.

  34. Doug says:

    Is there a way to modify this to show all folders for all users?
    Evenif my server or by db that would work, but would like to have it all in one if possible.
    Thanks
    Doug

  35. Ray Davis says:

    I have a question, I am trying to find a powershell script that will list out what the users have in sent item. Not the total sent, but what is a task item vs a stand email with a attachment.

    So like IPM.TASK and IPM.Note (examples) I wasn’t to see each sent email with a size and if its a task or not.

    Get-MailboxfolderStatistics username | select name, foldersize, itemsinFolder give me a overview.

    Is it possible how to determine this?

      • Peter says:

        Paul

        All I want to do is create a report showing email address, total item count and mailbox size from a txt file containing a load of email addresses and output to a csv file. Any chance of a script for that?

        Thanks

        Peter

  36. Kris Kirkbride says:

    Hi,

    Is there a way of JUST exporting the size and item count in the Inbox folder ONLY (not inbox subfolders) for all users in an entire organisation please??

  37. Dan Au says:

    Hi there,

    Is there a way to script this where to find an email address that was stuckk in all domain users draft folder?

    Thanks
    Dan

  38. Nicola says:

    I have 4 Exchange Databases (on different severs) and I would like a report that includes;

    Name
    Last Mailbox Logon
    Last Logon By
    Item Size (mb)
    Average Item Size (mb)
    Deleted Items Size (mb)
    No of Items.

    Any help would be great.

  39. Rob Mulder says:

    Hi Paul,

    I just want a list of all folders under the root (not only Inbox, Outbox etc but also folders created by the user) but NO subfolders list. How do I do that?

    So, this but then without listing all the subfolders….
    Get-MailboxFolderStatistics robert.muhren | Select Name,FolderPath,FolderandSubFolderSize,ItemsinFolderandSubfolders | Sort-Object FolderandSubFolderSize

  40. Adam C says:

    Hi Paul,

    Thanks for the great post,

    I have tried many variations of this and never managed to get it to work – currenty we are using Office365 and my code is: Get-Mailbox | Get-MailboxFolderStatistics | Where {$_.Name -match “Inbox”} | Select Identity, Name, ItemsInFolder | Sort-Object ItemsInFolder -descending | Export-csv c:InboxReport.csv

    The problem I have is that the ItemsInFolder count is always wrong, looking into it there is a microsoft article explaining why (https://support.microsoft.com/en-us/kb/3098973)

    Works perfectly for when I run it on Sent Items and Deleted Folders but never on the Inbox

    Do you have any ideas how I can get round this and get a true representation of the number of emails in a users inbox please?

    Thanks!

    A

  41. Alex says:

    If you want to get $_.FolderSize value represented in [decimal], please use following:

    $Folderstats = Get-MailboxFolderStatistics -identity $mailbox.Alias
    foreach ($folder in $Folderstats) {
    $s = $folder | Select-Object @{
    N = “FS_MB”;
    E = {
    [math]::round( ([decimal](($_.FolderSize -replace “[0-9.]+ [A-Z]* (([0-9,]+) bytes)”,”`$1″) -replace “,”,””) / 1MB),2)
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *