Email Security Monitoring in Microsoft 365 using API or PowerShell

Swahela Mulla 95 Reputation points
2023-07-05T09:07:07.4466667+00:00

Hello,

I'm currently working on creating a chart for Email Security Monitoring in Microsoft 365, and I would like to include the following counts: delivered, processed, spam, blocked by server, detonation protection, phishing, zero-hour auto archive, and malware.

Could you please suggest any API or PowerShell command that can provide me with the necessary data to generate these counts? I want to retrieve the count of emails falling into each of these categories to create an informative chart for monitoring email security.

I have come across some PowerShell commands that allow me to fetch data for these categories, but they seem to provide only the latest data (last 10 days). Is there a way to fetch older data, such as the data from the past 6 months? I would like to have a historical perspective in my chart.

Any guidance or examples would be greatly appreciated.

Thank you in advance for your assistance!

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Microsoft 365 and Office Install, redeem, activate For business Windows
Microsoft Security Microsoft Defender Microsoft Defender for Cloud
Windows for business Windows Server User experience PowerShell
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kael Yao 37,746 Reputation points Moderator
    2023-07-06T06:38:43.4966667+00:00

    Hi @Swahela Mulla

    I have come across some PowerShell commands that allow me to fetch data for these categories, but they seem to provide only the latest data (last 10 days). Is there a way to fetch older data, such as the data from the past 6 months? I would like to have a historical perspective in my chart.

    Do you mean Get-Messagetrace?

    Exchange Online can provide message trace result up to the last 90 days if you use the Start-HistoricalSearch cmdlet.

    Once the search is finished, you can download the report in Exchange Admin Center.

    For more detailed information this link may be helpful: Running Exchange Online Historical Message Traces

    (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.)


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.