8

We are currently looking at archiving emails and revamping our retention policy. The big question is (for the legal department), how far back do we want to save? Currently our users have a huge mailbox limit, and in the past have all been able to archive as they saw fit. So we have a couple hundred GB of data that isn't in the Exchange Database, but that we'd probably end up sucking into an Archive database for discovery. What I'd like to do is be able to quantify for the legal team how much that would be if we went back 1 year, 2 years, 3 years, etc.

I found a fairly straightforward Powershell Script at TheDailyAdmin that does what I want for the most part, but it lumps it all in one pile. I'd like to be able to see the results but sorted by user to know that Sally has 47MB that is older than 2 years, Charles has 190MB over 2 years old, etc.

Here is the script I've ran:

get-mailboxdatabase | get-mailbox -resultsize unlimited | get-mailboxfolderstatistics -folderscope all -includeoldestandnewestitems | export-csv mailbox_stats.csv

It works fine for putting them all in on file, but I can't tell who's email belongs to who. I also ran it on my mailbox specifically but I'd rather not run that manually on every user as that would take awhile! I'm not a Powershell guru but was hoping someone out there has a firmer grasp and can help point me in the right direction of the commands to help break it down a bit more.

Thanks in advance!

Don
  • 838
  • 8
  • 18
  • 33

4 Answers4

2

I was trying to solve this same problem and came up with the following.

You'll want to define $location as well as change the addyears(-1) to which ever number of years you want. In this example -1 is 1 year ago.

$Mailbox = Get-MailboxDatabase | Get-Mailbox

Foreach ($MBX in $Mailbox) {

$usermailbx = Get-Mailbox -identity $MBX | Get-MailboxStatistics
$userarchmailbx = Get-Mailbox -identity $MBX  | search-mailbox -SearchQuery "received<=$((get-date).addyears(-1).toString("yyyy-MM-ddTHH:mm:ssZ"))" -EstimateResultOnly
[pscustomobject]@{UserName=$usermailbx.displayname;TotalItemCount=$usermailbx.ItemCount;TotalItemSize=$usermailbx.totalitemsize.value;DeletedItemSize=$usermailbx.totaldeleteditemsize.value;ArchiveSize=$userarchmailbx.ResultItemsSize} | export-csv -append "$location\file.csv"
}
Nixphoe
  • 4,524
  • 7
  • 32
  • 51
1

Look into Multi-Mailbox Search/Discovery Search for what you need. You could get per-mailbox stats of individual folders by editing your existing script, but in order to get the size of all mail received within a date range reference the above link. It is not going to be a quick search by any means...

August
  • 3,114
  • 15
  • 17
0

I was looking for something similar.

I found this command:

Search-Mailbox "<user_name>" -SearchQuery 'Received<5/20/2018' -EstimateResultOnly

It is mentioned here: https://social.technet.microsoft.com/Forums/office/en-US/222ac7a6-8822-40c6-b4ad-75aac81a69f6/a-report-to-determine-emails-older-than?forum=exchange2010

it looks to work fine, but only up to 10.000 emails. For a 50+GB Mailbox, it is questionable

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
0

The Exchange PowerShell cmdlets don't provide a way to gather the statistics you're looking for. As you've discovered, it can only aggregate a folder; it can not break the statistics in to date ranges.

longneck
  • 22,793
  • 4
  • 50
  • 84
  • Well the date range thing is ok, I've just used an Excel filter to sort the items to only show anything older than 2 years. That seems to work ok, but what I can't tell is which folder belongs to which person. It's basically just put every folder from every person into one .csv with no path name to show who that folder belongs to. I was hoping there's one more parameter somewhere that can say something like, "-displayUserPath" that would clear it up for me. Thanks for the response! – Don Mar 08 '13 at 16:11