Solved

How to get send receive mails on my exchange 2007 server.

Posted on 2014-04-13
9
178 Views
Last Modified: 2014-04-30
Hi,

I have exchange 2007 server running on windows 2003. I have to present information to my management regarding how many mails are send received on my exchange server per day for all users.

request you to tell me a way out.
0
Comment
Question by:kapoor_sumeet
  • 5
  • 4
9 Comments
 
LVL 19

Expert Comment

by:Patricksr1972
ID: 39997218
Hi

In ESM you have a mailflow checker, do not specify a sender nor a reciever. Just check per day week month or whatever you want.
0
 

Author Comment

by:kapoor_sumeet
ID: 39997225
Will it give consolidated report on .


Sent mails:
Size of sent mails:
 Size of biggest mail out:
 Average size out:
 Quantity incoming mails:  
 Average size in :
 Overall quantity :
 Overall size :
0
 
LVL 19

Expert Comment

by:Patricksr1972
ID: 39997231
No it will not, it will only show sended and recieved mails.
To get deeper into what you want you can use a exchange powershell script as provided by MS to help you on your way. The link is here.
0
 

Author Comment

by:kapoor_sumeet
ID: 39997235
I have found following script.

$Localhost = $env:COMPUTERNAME
 #Load Exchange PS Snapin
 If ((Get-PSSnapin | Where-Object {$_.Name -eq “Microsoft.Exchange.Management.PowerShell.E2010¿} ).name -eq ‘Microsoft.Exchange.Management.PowerShell.E2010')
 {
 Write-Host “Exchange Snapin is already loaded….”
}

else
 {
 Write-Host “Loading Exchange Snapin Please Wait….”; Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
 }
 Write-Host “running…”

$hubs = Get-TransportServer

# Get the start date for the tracking log search
 $Start = (Get-Date -Hour 00 -Minute 00 -Second 00).AddDays(-1)

# Get the end date for the tracking log search
 $End = (Get-Date -Hour 23 -Minute 59 -Second 59).AddDays(-1)

$Datum = $Start.ToShortDateString()

$receive = $hubs | get-messagetrackinglog -Start $Start -End $End -EventID “RECEIVE” -ResultSize Unlimited | select Sender,RecipientCount,TotalBytes,Recipients
 $send = $hubs | get-messagetrackinglog -Start $Start -End $End -EventID “SEND” -ResultSize Unlimited | select Sender,RecipientCount,TotalBytes
 $mreceive = $receive | Measure-Object TotalBytes -maximum -minimum -average -sum
 $msend = $send | Measure-Object TotalBytes -maximum -minimum -average -sum

$anzahl = $mreceive.count + $msend.count
 $volumen = ($mreceive.sum + $msend.sum) / (1024 * 1024)

$volumen = “{0:N2}” -f $volumen + ” MB”

$msendmb = $msend.sum / (1024 * 1024)
 $vsend = “{0:N2}” -f $msendmb + ” MB”
$bigsend = $msend.maximum / (1024 * 1024)
 $avsend = $msend.average / 1024

$bigsendmb = “{0:N2}” -f $bigsend + ” MB”
$avsendkb = “{0:N2}” -f $avsend + ” KB”

$mreceivemb = $mreceive.sum / (1024 * 1024)
 $vreceive = “{0:N2}” -f $mreceivemb + ” MB”
$bigreceive = $mreceive.maximum / (1024 * 1024)
 $avreceive = $mreceive.average / 1024

$bigreceivemb = “{0:N2}” -f $bigreceive + ” MB”
$avreceivekb = “{0:N2}” -f $avreceive + ” KB”

#$senders = $send | Group-Object Sender | Sort-Object Count -Descending
 #$topsender = $senders[0].Name
 #$topsender += $senders[0].Count

#$receivers = $receive | Group-Object Recipients | Sort-Object Count -Descending
 #$topreceiver = $receivers[0]
 #$topreceiver

$computer = gc env:computername
 $obj = new-object psObject

$obj |Add-Member -MemberType noteproperty -Name “Generated on server:” -Value $Computer
 $obj |Add-Member -MemberType noteproperty -Name “Date :” -Value $Datum
 $obj |Add-Member -MemberType noteproperty -Name “Sent mails :” -Value $msend.Count
 $obj |Add-Member -MemberType noteproperty -Name “Size of sent mails:” -Value $vsend
 $obj |Add-Member -MemberType noteproperty -Name “Size of biggest mail out:” -value $bigsendmb
 $obj |Add-Member -MemberType noteproperty -Name “Average size out :” -value $avsendkb
 $obj |Add-Member -MemberType noteproperty -Name “Quantity incoming mails :” -Value $mreceive.Count
 $obj |Add-Member -MemberType noteproperty -Name “Size of received mails :” -Value $vreceive
 $obj |Add-Member -MemberType noteproperty -Name “Size of biggest mail in :” -value $bigreceivemb
 $obj |Add-Member -MemberType noteproperty -Name “Average size in :” -value $avreceivekb
 $obj |Add-Member -MemberType noteproperty -Name “Overall quantity :” -Value $anzahl
 $obj |Add-Member -MemberType noteproperty -Name “Overall size :” -Value $volumen

$out = $Datum + “;” + $msend.count + “;” + $vsend + “;” + $mreceive.count + “;” + $vreceive + “;” + $anzahl + “;” + $volumen
 $out | out-file c:\daily.csv -append -encoding default

function sendmail($body)
 {
 $SmtpClient = new-object system.net.mail.smtpClient
 $MailMessage = New-Object system.net.mail.mailmessage
 $SmtpClient.Host = “YOUR_HT_SERVER”
$mailmessage.from = “Exchange_2010_NoReply@YOURDOMAIN.COM”
$mailmessage.To.add(“RECIPIENT@YOURDOMAIN.COM”)
 # $mailmessage.CC.add(“CC_RECIPIENT@YOURDOMAIN.COM”)
 $mailmessage.Subject = “Exchange daily message Report $Datum”
$MailMessage.IsBodyHtml = $false
 $mailmessage.Body = $body

$smtpclient.Send($mailmessage)
 }

$obj = $obj -replace(“@{“,””)
 $obj = $obj -replace(“=”,”:`t”)
 $obj = $obj -replace(“; “,”`n”)
 $obj = $obj -replace(“}”,”`n”)

sendmail $obj


Now how to run this script. Will batch file work or there is some other way to run it.
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 19

Expert Comment

by:Patricksr1972
ID: 39997238
This is an powershell script which you need to call <filename>.ps1 and if i am not mistaken it needs the powershell snapin build into exchange (#Load Exchange PS Snapin)
0
 

Author Comment

by:kapoor_sumeet
ID: 39997249
Hi

Is powershell snapin there by default or it will load using this script. Other thing is if you can provide some link on how to run script.
0
 
LVL 19

Expert Comment

by:Patricksr1972
ID: 39997254
By installing Exchange 2007 you also get the exchange toolbox which allows you to run powershell scripts.

Here is a quick guide true on how to use, for example, a mail diagnostics script.
https://www.youtube.com/watch?v=lEn6mjY4zws
0
 

Author Comment

by:kapoor_sumeet
ID: 39997268
hi

if I run following command on exchange powershell

.\xyz.ps1

xyz.ps1 is the script file then it will run script. Is it  the way to run script .

 Please help me I have not used powershell before.
0
 
LVL 19

Accepted Solution

by:
Patricksr1972 earned 500 total points
ID: 39997272
Yes that is the way to run a powershell script.
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

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video discusses moving either the default database or any database to a new volume.

919 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

19 Experts available now in Live!

Get 1:1 Help Now