Solved

Exchange 2007 get count of messages sent and received for the day

Posted on 2010-09-22
3
3,168 Views
Last Modified: 2012-05-10
My manager was asking if there was any way to generate two "reports" from our exchange server. Ideally he would like a simple count of emails that were sent and received in a day. Something simple like

9/22/2010
Sent: 50,000
Received: 15,000

I dont know if this is possibly natively with exchange and powershell so Im hoping someone may know.
0
Comment
Question by:Joseph Daly
3 Comments
 
LVL 26

Assisted Solution

by:e_aravind
e_aravind earned 250 total points
Comment Utility
Process Tracking Log tool for Exchange Server 2007
http://msexchangeteam.com/archive/2008/02/07/448082.aspx
0
 
LVL 8

Accepted Solution

by:
Mkris9 earned 250 total points
Comment Utility
0
 
LVL 12

Expert Comment

by:GusGallows
Comment Utility
I generate the same report using the following PowerShell script:

#get a list of all hub servers (use the @() syntax so it will treat it as
#an array even if there is only one hub server)
$Hubs = @(Get-TransportServer)

#Get today's date for the output file
$date = ( get-date ).ToString('MM/dd/yyyy')

#Create the output file
$Out = "c:\temp\MsgCount.txt"

#Clear your counter variables
$Sent = 0
$Sent1 = 0
$Rcvd = 0
$Rcvd1 = 0

#Get today's date/time for the message logs
$EDate = get-date -uFormat '%D %r'

#Get date/time for the last 24 hours
$SDate = (get-date (get-date).AddDays(-1) -uformat '%D %r')

#go through each hub and count the messages for the Sent and Receive EventIDs.
#***NOTE*** Receive may or may not be what you are looking for. You can also
#try it with the Deliver EventID

foreach ($Hub in $Hubs)
{
      #count Sent messages
      $msg = @(get-messagetrackinglog -Server $Hub -EventID "Send" -Start "$SDate" -End "$EDate" -ResultSize Unlimited)
      $Sent1 = $msg.Count
      #add to total for all Hub servers
      $Sent = $Sent + $Sent1
      
      #Count received messages
      $msg2 = @(get-messagetrackinglog -Server $Hub -EventID "Receive" -Start "$SDate" -End "$EDate" -ResultSize Unlimited)
      $Rcvd1 = $msg2.Count
      #add to total for all hub servers
      $Rcvd = $Rcvd + $Rcvd1
}      

#Create your output and write it to the output file
out-File $Out -InputObject $date
$inp = "Sent: " + $Sent
out-File $Out -InputObject $inp -Append
$inp2 = "Received: " + $Rcvd
out-File $Out -InputObject $inp2 -Append

# Send Email with attached output file
Function Send-Mail
{
 $mail = New-Object Net.Mail.MailMessage
#Specify what email address to send the report from
 $mail.From  = "MsgReport@domain.com"
#Specify the recipient's email address
 $mail.To.Add("bossesEmail@domain.com")
 $mail.Subject = "Daily Message Count"
 $mail.Body = "Script generated report."
 $Attachment = New-Object Net.Mail.Attachment($Out)
 $mail.Attachments.Add($Attachment)
 $smtp = New-Object Net.Mail.SmtpClient
#Specify you SMTP Server
 $smtp.Host = "SMTPServer.domain.com"
 $smtp.Port = "25"
 $smtp.Send($mail)
}
Send-Mail
0

Featured Post

Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now