Shared Mailbox Audit in 365

Copper Contributor

I have been tasked with a review of all our Shared Mailboxes in my companies Tenant.  We have around 550 to be looked at.  What I need to know is the last date an email was received into the Shared Mailbox and the last time a mail was sent from it.

 

Anyone do anything similar?

 

Cannot use get-messagetrace as it only goes back 10 days max, ideally, I would need to be able to see at least 6 months back, longer if possible.

1 Reply

Hi @coxygt 

 

One option mught be to use the Get-MailboxFolderStatistics cmdlet and the IncludeOldestAndNewestItems parameter which will return the dates of the oldest and newest items in each folder

 

Here's a sample script  to get you started:

 

$sharedMailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited

$sharedMailboxes | ForEach-Object {
    $mailboxStats = Get-MailboxFolderStatistics -Identity $_.Guid -IncludeOldestAndNewestItems

    [PSCustomObject]@{
        Mailbox   = $_.Identity
        Inbox     = ($mailboxStats | Where-Object { $_.FolderType -eq 'Inbox' }).NewestItemReceivedDate
        SentItems = ($mailboxStats | Where-Object { $_.FolderType -eq 'SentItems' }).NewestItemReceivedDate
    }
}