Forum Discussion
coxygt
Jul 26, 2023Brass Contributor
Shared Mailbox Audit in 365
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 M...
kevkelly
Jul 26, 2023MCT
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
}
}