Get size of emails older than 180 days

Hello,

I am currently in the process of building a business case to acquire an archiving solution (to archive my 50gb+ mailboxes...) and am in need to figure out how much space I would "save".

I want to get the total size of the emails older than 180days per MailboxDatabase.

I tried using Search-Mailbox but it is only returning up to 10000 results where some of my mailboxes have over 100k items.

I then tried to use New-MailboxSearch but it can't see how to easily script it to send it to a CSV as it runs it as a background task..

Has anyone ever done this or does anyone have any pointer to help me?

Thanks,

Michel

July 7th, 2015 7:56am

First script to get report:

Get-Mailbox | Get-MailboxStatistics | where {$_.Lastlogontime -lt (get-date).AddDays(-180)} | Select DisplayName,ItemCount,totalitemsize,LastLogonTime

Another one to measure results:

Get-Mailbox  | Get-MailboxStatistics | where {$_.Lastlogontime -lt (get-date).AddDays(-180)} | %{$_.TotalItemSize.Value.ToGB()} | measure-object -sum -ave -max -min

You can add Get-Mailbox -Database DatabaseName property as well.
Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 9:30am

Hi Slava,

This would give me the users who last accessed their mailbox, not the amount and size of emails older than 180 days including those who still access their mailboxes.

I think I figured out a way though. I have written the following scripts which seem to work..

To create new mailbox searches, one for each DB.. (uncomment the first two lines if ran from Exchange shell)

#Import-Module "C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1"
#Connect-ExchangeServer exchangeserverFQDN
$endDate=(get-date).adddays(-180)

$DBs = Get-MailboxDatabase -IncludePreExchange2013

foreach ($DB in $DBs) {
$mailboxes = Get-Mailbox -Database $DB
New-MailboxSearch -name $DB.name -SourceMailboxes $mailboxes -EndDate $endDate -EstimateOnly
Start-MailboxSearch $DB.name
}

And then I have to monitor completion using Get-MailboxSearch. Once all of them are completed, I can run the following script to export the data to a CSV.. I have yet to run it to confirm as the first script hasn't completed it's first run..

#Import-Module "C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1"
#Connect-ExchangeServer exchangeserverFQDN
$file = oldEmails.csv
$mailboxSearch = Get-MailboxSearch | Select-Object Name,NumberMailboxToSearch,ResultNumberEstimate,ResultSizeEstimate.toGB()
$append = $false

foreach ($search in $mailboxSearch) {
if ($append -eq $false) {
$search | Export-Csv $file
$append = $true
}
else {
$search | Export-Csv $file -Append
}
}
I'll update once I confirm that both of the scripts work well.


July 7th, 2015 9:36am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics