Script to get daily mail flow for last 24 hours

Amazumda 21 Reputation points
2021-02-22T08:34:45.29+00:00

Hello Team,

I want to know if we have any script to get daily mail flow for last 24 hours for exchange online and then send an automated email to the management or admin mailbox .

Thank you for your help 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,168 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,359 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Vasil Michev 95,081 Reputation points MVP
    2021-02-22T09:28:10.627+00:00

    You have to be a bit more specific here, which details are you looking for exactly? There are some reports within the M365 Admin Center and the SCC that give you information around mail flow, some of these can be queried by PowerShell too so they are easy to automate - the question is are they of use to you, and if so, which ones exactly?

    0 comments No comments

  2. Chris 651 Reputation points
    2021-02-22T16:49:28.653+00:00

    take a look of https://www.frankysweb.de/exchange-reporter-2013/

    you can change ini from 7 days to 1 day

    0 comments No comments

  3. Lucas Liu-MSFT 6,161 Reputation points
    2021-02-23T04:22:00.187+00:00

    Hi @Amazumda ,
    According to my test and research, Exchange online itself cannot realize the function of automatically sending related reports. But Exchange online can query mail flow information in the following ways:
    1.You could view the email activity report in Microsoft 365 admin center:
    70850-1.png

    2.You could run the following command to view the message trace, but please noted that you could use this cmdlet to search message data for the last 10 days. If you run this cmdlet without any parameters, only data from the last 48 hours is returned.

    Get-Messagetrace -Start <> -End <>  
    

    70877-image.png

    3.In addition, you could run the script in the following link. It will output your mail flow information within a specific period of time. You can refer to the following link for specific script usage:
    Please refer to: Office 365 Reports
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    70912-3.png


    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.