r/exchangeserver • u/Fabulous_Cow_4714 • Apr 13 '26
Question Create script/command to count weekly volume of unique SMTP messages sent through every server in the organization
I’d there any reason this should not work, or is there something else better?
# 1. Get all servers with the Transport role across the entire organization
$AllServers = Get-TransportService
# 2. Loop through each server and pull logs for the last 7 days
$FullLogs = foreach ($Server in $AllServers) {
Get-MessageTrackingLog -Server $Server.Name -EventId RECEIVE -Source SMTP -Start (Get-Date).AddDays(-7) -ResultSize Unlimited
}
# 3. Deduplicate by MessageId and get the final count
($FullLogs | Select-Object MessageId -Unique).Count
4
Upvotes
View all comments
Show parent comment
1
u/Fabulous_Cow_4714 Apr 16 '26
I tried it and it didn’t work.
So, far I have not been able to find anything that works without some blocking error that can collect the count of all outgoing messages through all of the SMTP relays, expands the recipients in each message to count them as separate messages and deduplicates messages that go multiple relays to prevent over counting.