Solved

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

Posted on 2010-09-22
3
3,188 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
ID: 33734872
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
ID: 33734880
0
 
LVL 12

Expert Comment

by:GusGallows
ID: 33743444
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
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 show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

914 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

16 Experts available now in Live!

Get 1:1 Help Now