You are searching for the folder inside a mailbox that contains the oldest message.
Mailbox folders can be scanned specifying certain criteria. This one-liner takes advantage of the OldestItemReceivedDate property of the MailboxDatabaseFolder query output. It crawls through all the folders in the mailbox and retrieves the receive date of the oldest email, accompanied with the relative folder path inside the mailbox.
Script
Get-Mailbox [mailbox] | Get-MailboxFolderStatistics -IncludeOldestAndNewestItems | ?{$_.OldestItemReceivedDate -ne $null} | Select -Property OldestItemReceivedDate,Folderpath | Sort -Property OldestItemReceivedDate
Example
We check the folders inside John Doe's mailbox, displaying only those that contain emails and sort them, putting the oldest to the top
PS C:\> Get-Mailbox john.doe@alwayshotcafe.com | Get-MailboxFolderStatistics -IncludeOldestAndNewestItems | ?{$_.OldestItemReceivedDate -ne $null} | Select -Property OldestItemReceivedDate,Folderpath | Sort -Property OldestItemReceivedDate
OldestItemReceivedDate FolderPath
---------------------- ----------
26/10/2007 14:14:08 /Deletions
21/12/2015 15:55:49 /Calendar Logging
13/04/2020 12:35:47 /Contacts/Recipient Cache
13/04/2020 12:36:11 /Sent Items
13/04/2020 12:37:06 /Inbox
PS C:\>

Comments