skip to Main Content

Get Exchange Online mail traffic report with PowerShell

Companies like to know how many emails they get an hour or a day. Perhaps they want to gather the total inbound mail and outbound mail for their analytics. With the Get-MailTrafficReport cmdlet in PowerShell, we can check the total inbound and outbound mail and a bunch more. Let’s find out more about how to get Exchange Online mail traffic report with PowerShell.

Connect to Exchange Online PowerShell

Make a connection to Exchange Online PowerShell. Run Windows PowerShell as administrator and connect to Exchange Online PowerShell V2.

PS C:\> Connect-ExchangeOnline

After connecting, let’s proceed to the next step.

Get mail traffic report

Run Get-MailTrafficReport cmdlet. The cmdlet is only available for Exchange Online and not for Exchange on-premises. It will output Exchange Online traffic summary. The output of the last seven days is showing.

PS C:\> Get-MailTrafficReport | Format-Table Date,EventType,Direction,Action,MessageCount

Date              EventType                 Direction Action       MessageCount
----              ---------                 --------- ------       ------------
1-6-2021 00:00:00 SpoofMailCompAuthResult             fail                 1920
1-6-2021 00:00:00 SpoofMailCompAuthResult             none                    1
1-6-2021 00:00:00 SpoofMailCompAuthResult             pass                 1599
1-6-2021 00:00:00 SpoofMailCompAuthResult             softpass              796
1-6-2021 00:00:00 BCL0                      Inbound                        3595
1-6-2021 00:00:00 BCL1                      Inbound                        1504
1-6-2021 00:00:00 BCL2                      Inbound                          74
1-6-2021 00:00:00 BCL3                      Inbound                          49
1-6-2021 00:00:00 BCL4                      Inbound                          20
1-6-2021 00:00:00 BCL5                      Inbound                           2
1-6-2021 00:00:00 BCL6                      Inbound                           8
1-6-2021 00:00:00 BCL8                      Inbound                           1
1-6-2021 00:00:00 GoodMail                  Inbound                        5127
1-6-2021 00:00:00 NonSpam_AllowList         Inbound                         487
1-6-2021 00:00:00 NonSpam_ContentScanPassed Inbound                        4383
1-6-2021 00:00:00 Receive                   Inbound   TotalMsg                1
1-6-2021 00:00:00 Spam_BlockList            Inbound                           2
1-6-2021 00:00:00 Spam_ContentScanFiltered  Inbound                         110
1-6-2021 00:00:00 Spam_SenderBlocked        Inbound                          23
1-6-2021 00:00:00 SpamContentFiltered       Inbound                         135
1-6-2021 00:00:00 SpamDBEBFilter            Inbound                           2
1-6-2021 00:00:00 SpamIPBlock               Inbound                         607
1-6-2021 00:00:00 SpoofMail                 Inbound   CaughtAsSpam           57
1-6-2021 00:00:00 SpoofMail                 Inbound   GoodMail             5532
1-6-2021 00:00:00 BCL0                      Outbound                       7859
1-6-2021 00:00:00 EncryptionManual          Outbound  Encrypt                 1
1-6-2021 00:00:00 GoodMail                  Outbound                       8197
1-6-2021 00:00:00 NonSpam_ContentScanPassed Outbound                       1762
1-6-2021 00:00:00 NonSpam_ETRPassed         Outbound                        252
1-6-2021 00:00:00 NonSpam_IntraOrg          Outbound                       6162

Let’s go a little bit more in details and get a separate mail report for inbound and outbound.

Get mail traffic report inbound

Filter report by day

Filter on inbound mail by day. In this example, we did select June 3, 2021.

PS C:\> Get-MailTrafficReport -Direction Inbound -StartDate "06/03/2021 00:00" -EndDate "06/03/2021 00:00" | Format-Table Date,EventType,Direction,Action,MessageCount

Date              EventType                 Direction Action       MessageCount
----              ---------                 --------- ------       ------------
3-6-2021 00:00:00 BCL0                      Inbound                        3328
3-6-2021 00:00:00 BCL1                      Inbound                        1187
3-6-2021 00:00:00 BCL2                      Inbound                          72
3-6-2021 00:00:00 BCL3                      Inbound                          55
3-6-2021 00:00:00 BCL4                      Inbound                          25
3-6-2021 00:00:00 BCL7                      Inbound                           1
3-6-2021 00:00:00 BCL8                      Inbound                           1
3-6-2021 00:00:00 GoodMail                  Inbound                        4552
3-6-2021 00:00:00 NonSpam_AllowList         Inbound                          73
3-6-2021 00:00:00 NonSpam_ContentScanPassed Inbound                        4188
3-6-2021 00:00:00 Receive                   Inbound   TotalMsg                1
3-6-2021 00:00:00 Spam_BlockList            Inbound                           1
3-6-2021 00:00:00 Spam_BulkFiltered         Inbound                           1
3-6-2021 00:00:00 Spam_ContentScanFiltered  Inbound                         107
3-6-2021 00:00:00 Spam_SenderBlocked        Inbound                          14
3-6-2021 00:00:00 SpamContentFiltered       Inbound                         123
3-6-2021 00:00:00 SpamDBEBFilter            Inbound                           1
3-6-2021 00:00:00 SpamIPBlock               Inbound                         547
3-6-2021 00:00:00 SpoofMail                 Inbound   CaughtAsSpam           52
3-6-2021 00:00:00 SpoofMail                 Inbound   GoodMail             4950

Filter report by good mail

Filter mail traffic report by the event type GoodMail. GoodMail messages are delivered after passing through the malware and spam filters. This count shows the number of unique messages. If a message were delivered to multiple recipients, it would still count as a single message.

PS C:\> Get-MailTrafficReport -Direction Inbound -StartDate "06/03/2021 00:00" -EndDate "06/03/2021 00:00" -EventType GoodMail | Format-Table Date,EventType,Direction,MessageCount

Date              EventType Direction MessageCount
----              --------- --------- ------------
3-6-2021 00:00:00 GoodMail  Inbound           4552

Filter report aggregate by hour

Add the AggregateBy parameter with the value Hour. The AggregateBy parameter specifies the reporting period. Valid values are Hour, Day, or Summary. The default value is Day.

PS C:\> Get-MailTrafficReport -Direction Inbound -StartDate "06/03/2021 00:00" -EndDate "06/03/2021 00:00" -EventType GoodMail -AggregateBy Hour | Format-Table Date,EventType,Direction,MessageCount    

Date              EventType Direction MessageCount
----              --------- --------- ------------
3-6-2021 00:00:00 GoodMail  Inbound              3
3-6-2021 01:00:00 GoodMail  Inbound             17
3-6-2021 02:00:00 GoodMail  Inbound              5
3-6-2021 03:00:00 GoodMail  Inbound             26
3-6-2021 04:00:00 GoodMail  Inbound             60
3-6-2021 05:00:00 GoodMail  Inbound            113
3-6-2021 06:00:00 GoodMail  Inbound            256
3-6-2021 07:00:00 GoodMail  Inbound            392
3-6-2021 08:00:00 GoodMail  Inbound            492
3-6-2021 09:00:00 GoodMail  Inbound            335
3-6-2021 10:00:00 GoodMail  Inbound            400
3-6-2021 11:00:00 GoodMail  Inbound            381
3-6-2021 12:00:00 GoodMail  Inbound            275
3-6-2021 13:00:00 GoodMail  Inbound            454
3-6-2021 14:00:00 GoodMail  Inbound            297
3-6-2021 15:00:00 GoodMail  Inbound            227
3-6-2021 16:00:00 GoodMail  Inbound            101
3-6-2021 17:00:00 GoodMail  Inbound             97
3-6-2021 18:00:00 GoodMail  Inbound             45
3-6-2021 19:00:00 GoodMail  Inbound            487
3-6-2021 20:00:00 GoodMail  Inbound             37
3-6-2021 21:00:00 GoodMail  Inbound             25
3-6-2021 22:00:00 GoodMail  Inbound             15
3-6-2021 23:00:00 GoodMail  Inbound             12

Filter report by month

Do you want to check how much good inbound mail the last month was? Let’s get the good mail of the last month May 2021, which is 31 days.

PS C:\> Get-MailTrafficReport -Direction Inbound -StartDate "05/01/2021 00:00" -EndDate "05/31/2021 00:00" -EventType GoodMail | Format-Table Date,EventType,Direction,MessageCount

Date               EventType Direction MessageCount
----               --------- --------- ------------
1-5-2021 00:00:00  GoodMail  Inbound            730
2-5-2021 00:00:00  GoodMail  Inbound            624
3-5-2021 00:00:00  GoodMail  Inbound           4774
4-5-2021 00:00:00  GoodMail  Inbound           5030
5-5-2021 00:00:00  GoodMail  Inbound           1832
6-5-2021 00:00:00  GoodMail  Inbound           4039
7-5-2021 00:00:00  GoodMail  Inbound           2530
8-5-2021 00:00:00  GoodMail  Inbound            540
9-5-2021 00:00:00  GoodMail  Inbound            495
10-5-2021 00:00:00 GoodMail  Inbound           4120
11-5-2021 00:00:00 GoodMail  Inbound           4381
12-5-2021 00:00:00 GoodMail  Inbound           3324
13-5-2021 00:00:00 GoodMail  Inbound            650
14-5-2021 00:00:00 GoodMail  Inbound           1068
15-5-2021 00:00:00 GoodMail  Inbound            518
16-5-2021 00:00:00 GoodMail  Inbound            527
17-5-2021 00:00:00 GoodMail  Inbound           4268
18-5-2021 00:00:00 GoodMail  Inbound           4814
19-5-2021 00:00:00 GoodMail  Inbound           3545
20-5-2021 00:00:00 GoodMail  Inbound           4059
21-5-2021 00:00:00 GoodMail  Inbound           2835
22-5-2021 00:00:00 GoodMail  Inbound            439
23-5-2021 00:00:00 GoodMail  Inbound            836
24-5-2021 00:00:00 GoodMail  Inbound           1162
25-5-2021 00:00:00 GoodMail  Inbound           4717
26-5-2021 00:00:00 GoodMail  Inbound           3664
27-5-2021 00:00:00 GoodMail  Inbound           4045
28-5-2021 00:00:00 GoodMail  Inbound           2643
29-5-2021 00:00:00 GoodMail  Inbound            714
30-5-2021 00:00:00 GoodMail  Inbound            538
31-5-2021 00:00:00 GoodMail  Inbound           4078

Get total inbound messages by month

Let’s see how many messages the good mail inbound was for May 2021. Add the Measure-Object cmdlet to calculate the Average, Sum, Maximum, and Minimum numeric values. We can see that the total inbound for May 2021 was 77539 messages.

PS C:\> Get-MailTrafficReport -Direction Inbound -StartDate "05/01/2021 00:00" -EndDate "05/31/2021 00:00" -EventType GoodMail -AggregateBy Day | Measure-Object "MessageCount" -Average -Sum -Maximum -Minimum

Count    : 31
Average  : 2501,25806451613
Sum      : 77539
Maximum  : 5030
Minimum  : 439
Property : MessageCount

Everything looks great. Let’s do the same, but this time with outbound mail traffic.

Get mail traffic report outbound

Filter report by day

Filter on outbound mail by day. In this example, we did select June 3, 2021. The only difference between the previous cmdlet is to set the value Outbound instead of Inbound.

PS C:\> Get-MailTrafficReport -Direction Outbound -StartDate "06/03/2021 00:00" -EndDate "06/03/2021 00:00" | Format-Table Date,EventType,Direction,MessageCount

Date              EventType                 Direction MessageCount
----              ---------                 --------- ------------
3-6-2021 00:00:00 BCL0                      Outbound          7708
3-6-2021 00:00:00 BCL1                      Outbound             3
3-6-2021 00:00:00 GoodMail                  Outbound          8086
3-6-2021 00:00:00 NonSpam_ContentScanPassed Outbound          1750
3-6-2021 00:00:00 NonSpam_ETRPassed         Outbound           393
3-6-2021 00:00:00 NonSpam_IntraOrg          Outbound          5920
3-6-2021 00:00:00 NonSpam_IPAllowed         Outbound           390

Filter report by good mail

Filter mail traffic report by the event type GoodMail.

PS C:\> Get-MailTrafficReport -Direction Outbound -StartDate "06/03/2021 00:00" -EndDate "06/03/2021 00:00" -EventType GoodMail | Format-Table Date,EventType,Direction,MessageCount

Date              EventType Direction MessageCount
----              --------- --------- ------------
3-6-2021 00:00:00 GoodMail  Outbound          8086

Filter report aggregate by hour

Add the AggregateBy parameter with the value Hour.

PS C:\> Get-MailTrafficReport -Direction Outbound -StartDate "06/03/2021 00:00" -EndDate "06/03/2021 00:00" -EventType GoodMail -AggregateBy Hour | Format-Table Date,EventType,Direction,MessageCount   

Date              EventType Direction MessageCount
----              --------- --------- ------------
3-6-2021 01:00:00 GoodMail  Outbound             1
3-6-2021 02:00:00 GoodMail  Outbound             2
3-6-2021 03:00:00 GoodMail  Outbound            11
3-6-2021 04:00:00 GoodMail  Outbound            90
3-6-2021 05:00:00 GoodMail  Outbound           264
3-6-2021 06:00:00 GoodMail  Outbound           401
3-6-2021 07:00:00 GoodMail  Outbound           760
3-6-2021 08:00:00 GoodMail  Outbound           819
3-6-2021 09:00:00 GoodMail  Outbound           830
3-6-2021 10:00:00 GoodMail  Outbound           845
3-6-2021 11:00:00 GoodMail  Outbound           889
3-6-2021 12:00:00 GoodMail  Outbound           800
3-6-2021 13:00:00 GoodMail  Outbound           914
3-6-2021 14:00:00 GoodMail  Outbound           644
3-6-2021 15:00:00 GoodMail  Outbound           383
3-6-2021 16:00:00 GoodMail  Outbound           117
3-6-2021 17:00:00 GoodMail  Outbound            62
3-6-2021 18:00:00 GoodMail  Outbound            43
3-6-2021 19:00:00 GoodMail  Outbound            79
3-6-2021 20:00:00 GoodMail  Outbound            29
3-6-2021 21:00:00 GoodMail  Outbound            23
3-6-2021 22:00:00 GoodMail  Outbound             7
3-6-2021 23:00:00 GoodMail  Outbound            73

Filter report by month

Get good mail for the last month May 2021, which is 31 days.

PS C:\> Get-MailTrafficReport -Direction Outbound -StartDate "05/01/2021 00:00" -EndDate "05/31/2021 00:00" -EventType GoodMail | Format-Table Date,EventType,Direction,MessageCount

Date               EventType Direction MessageCount
----               --------- --------- ------------
1-5-2021 00:00:00  GoodMail  Outbound           316
2-5-2021 00:00:00  GoodMail  Outbound           316
3-5-2021 00:00:00  GoodMail  Outbound          8066
4-5-2021 00:00:00  GoodMail  Outbound          8677
5-5-2021 00:00:00  GoodMail  Outbound          1540
6-5-2021 00:00:00  GoodMail  Outbound          7403
7-5-2021 00:00:00  GoodMail  Outbound          5067
8-5-2021 00:00:00  GoodMail  Outbound           251
9-5-2021 00:00:00  GoodMail  Outbound           317
10-5-2021 00:00:00 GoodMail  Outbound          8395
11-5-2021 00:00:00 GoodMail  Outbound          8878
12-5-2021 00:00:00 GoodMail  Outbound          6851
13-5-2021 00:00:00 GoodMail  Outbound           404
14-5-2021 00:00:00 GoodMail  Outbound           667
15-5-2021 00:00:00 GoodMail  Outbound           267
16-5-2021 00:00:00 GoodMail  Outbound           473
17-5-2021 00:00:00 GoodMail  Outbound          8202
18-5-2021 00:00:00 GoodMail  Outbound          8700
19-5-2021 00:00:00 GoodMail  Outbound          6527
20-5-2021 00:00:00 GoodMail  Outbound          7725
21-5-2021 00:00:00 GoodMail  Outbound          5155
22-5-2021 00:00:00 GoodMail  Outbound           303
23-5-2021 00:00:00 GoodMail  Outbound           259
24-5-2021 00:00:00 GoodMail  Outbound           718
25-5-2021 00:00:00 GoodMail  Outbound          7872
26-5-2021 00:00:00 GoodMail  Outbound          6645
27-5-2021 00:00:00 GoodMail  Outbound          7403
28-5-2021 00:00:00 GoodMail  Outbound          5502
29-5-2021 00:00:00 GoodMail  Outbound           291
30-5-2021 00:00:00 GoodMail  Outbound           322
31-5-2021 00:00:00 GoodMail  Outbound          8127

Get total outbound messages by month

The total outbound for May 2021 was 131639 messages.

PS C:\> Get-MailTrafficReport -Direction Outbound -StartDate "05/01/2021 00:00" -EndDate "05/31/2021 00:00" -EventType GoodMail -AggregateBy Day | Measure-object "MessageCount" -Average -Sum -Maximum -Minimum


Count    : 31
Average  : 4246,41935483871
Sum      : 131639
Maximum  : 8878
Minimum  : 251
Property : MessageCount

That’s it!

Read more: Whitelist domain in Office 365 to bypass SPAM filtering »

Conclusion

In this article, we showed how to get Exchange Online mail traffic report with PowerShell. By running the cmdlets, you will have different mail traffic reports with a lot of information. We were looking for the total number of delivered inbound (incoming) and outbound (outgoing) messages a month. The Get-MailTrafficReport cmdlet is excellent to use.

Did you enjoy this article? You may also like Get mailbox size greater than in Office 365. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *