Solved

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

Posted on 2010-09-22
3
3,234 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
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…

776 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