question

ClaireHicken-3971 avatar image
0 Votes"
ClaireHicken-3971 asked KyleXu-MSFT commented

Powershell to determin how many emails are over 2 years old O365

Hi

Can anyone help me? We have a Hybrid on-prem Exchange / O365 environment

I am trying to find a way to produce a report which will give me a total number of emails per user that are over 2 years old, I don't want to know any details of the email, I just want a count of how many there are.


Thanks in advance.


office-exchange-server-administrationoffice-exchange-online-itprooffice-exchange-hybrid-itpro
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ClaireHicken-3971
I am writing here to confirm with you any update about this thread now?
If the suggestion below helps, please be free to mark it as an answer for helping more people.

0 Votes 0 ·

1 Answer

KyleXu-MSFT avatar image
0 Votes"
KyleXu-MSFT answered

@ClaireHicken-3971

You need to user "New-MailboxSearch" command to create mailbox search for those mailboxes:

 Get-Mailbox | where{$_.RecipientTypeDetails -eq "UserMailbox"} |foreach{ New-MailboxSearch -Name $_.Name  -SourceMailboxes $_.Name -StartDate "08/29/2019" -EndDate "8/30/2021" -EstimateOnly}

Then use command below to start those search requests:

 Get-MailboxSearch | Start-MailboxSearch

Wait a long time, because the Mailbox Search may take a long time to run.
Then, you could use command below to check the completed search request:

 Get-MailboxSearch | where{$_.Status -eq "EstimateSucceeded"} | fl Name,ResultNumberEstimate 

You could use command below to check status for all requests:

 Get-MailboxSearch

If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.