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

Claire Hicken 1 Reputation point
2021-08-27T14:54:28.02+00:00

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.

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,308 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,429 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,954 questions
{count} votes

1 answer

Sort by: Most helpful
  1. KyleXu-MSFT 26,226 Reputation points
    2021-08-30T02:03:59.407+00:00

    @Claire Hicken

    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.

    0 comments No comments