This script is working fine. but i would like to know the Specific Domain name sent items. or i would like to know what is the total sent item for internal.
Say as example my domain is ABC.com. i would like to know what is the total sent items for ABC.com to ABC.com (Total Sent items only). Please advise how to do this.
Thank you looking forward.
#Powershell
$nl = [Environment]::NewLine
#Mailbox to gather stats on
#$mailbox=""
#Get todays date twice
$startDate=Get-Date
$endDate=Get-Date
$domain= "aniyanetworks.net"
#Subtract 1 day from todays date (report ending day) and 7 days from todays date (report starting day)
$startDateFormatted=$startDate.AddDays(-32).ToShortDateString()
$endDateFormatted=$endDate.AddDays(-1).ToShortDateString()
#Who to send the e-mail report to.
#Multiple e-mail addresses should be in this format ", "
$emailFrom = "Monthly-Email-Tracking@aniyanetworks.net"
$emailTo = "sysadmin@aniyanetworks.net"
$subject = "Monthly e-mail report for $domain for $startDateFormatted - $endDateFormatted"
$smtpServer = "exchange1.aniyanetworks.net"
# Sent e-mails
#$sendCount = Get-TransportServer | Get-MessageTrackingLog -Start "$startDateFormatted 00:00:00" -End "$endDateFormatted 23:59:59" -Sender $mailbox -resultsize unlimited | select-object -unique MessageId
$sendCount = Get-TransportServer | Get-MessageTrackingLog -EventId Send -Start "$startDateFormatted 00:00:00" -End "$endDateFormatted 23:59:59" -resultsize unlimited
#$sendCount = Get-TransportServer | Get-MessageTrackingLog -EventId Send -Start "03/14/2016 00:00:00" -End "04/14/2016 23:59:59" -resultsize unlimited
#$sendCount.count
# Received e-mails - This works but not on generic accounts
#$receiveCount = Get-TransportServer | Get-MessageTrackingLog -Start "$startDateFormatted 00:00:00" -End "$endDateFormatted 23:59:59" -Recipients $mailbox -resultsize unlimited | select-object -unique MessageId
$sendCountString = $sendCount.count
So this will give me Total Count of all the Sent items.
but i would like to know only my domain to my domain sent items.
such as , from *@aniyanetworks.net to *@aniyanetworks.net
please advise.