0
votes

I'm looking to run a script like this and export to a CSV and sort by the last time the mailbox was used. Basically we're trying to find mailboxes that haven't been used for more than 60 days. Once we load the list, we will run the script again except add a bit of code to export each mailbox to PST (I'm not sure how to do that portion, either)

The mailboxes were recently migrated from Exch 2007. The mailboxes are backed up on a daily basis, so access time won't work.

I was looking at something like the below, but I get an error that it cannot get-mailboxstatistics from a mailbox on a server running version 8 while the script is running on version 14. This is likely because there are a large number of mailboxes we left on an Exchange 2007 server which are all terminated users. I would like to include these in the search results.

$xDays = 60 

Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | Foreach-Object { 

$si= Get-MailboxFolderStatistics $_ -IncludeOldestAndNewestItems -FolderScope SentItems 

if($si.NewestItemReceivedDate -AND (New-TimeSpan $si.NewestItemReceivedDate.ToLocalTime()).Days -ge $xDays) 
{ 
$_ 
} 

} 
1

1 Answers

0
votes

You will probably need to run the script separately from 2007 and 2010 as it says.

Run it like this from the 2007 server:

Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox -Server "2007 Server"

Like this from the 2010 server:

Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox -Server "2010 Server"