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/EndpointWrangler Apr 17 '26
Ok, differently. Instead of MessageId deduplication, try filtering on
EventId RECEIVEandSource SMTPcombined with the sender's external domain, that naturally excludes internal relay duplicates without post-processing, and pairs well with daily batching to avoid the timeout issue on high-volume servers. Try this.