I have found lots of scripts/reports to get emails sent by recipients with counts and such. I am looking for a script to just get received emails counts to my accepted domains from the internet. I found the below script from Mike Pfeiffer's(Thanks) Exchange Cookbook.
$Domain=@{}
$report=Get-TransportServer |
Get-MessageTrackingLog -EventId "Send" -ResultSize Unlimited -Start (Get-Date).AddDays(-30)
Where-Object {$_.ConnectorID -eq '*\Internet'}
if($report) {
$domains=$report | %{$_.Recipients | %{$_.Split("@")[1]}}
$domains | %{$domain[$_] = $domain[$_] + 1}
Write-Output $domain > "C:\MessageCountAcceptedDomain.txt"
}
I am trying to modify the above script or if anyone has one. I need to deprecate some of my smtp domains. We have a few old ones and would like to clean it up. The above script gets all email. I have tried using where-object
#| where-object {$domain -like "*@domain1.com"}
#| where-object {$_.domainname -like "*@domain1.com"}
No luck. Any ideas?