Solved

How can I count physical emails sent from all mailboxes?

Posted on 2010-08-23
10
801 Views
Last Modified: 2012-08-13
I need to know how many "physical" emails my users sent during a specific date. I used the program below to export the RECEIVE events on my hub, but I can't figure out how to count them per mailbox.

foreach ($x in get-mailbox -server MYMAILBOXSERVER -resultsize unlimited | %{$_.primarysmtpaddress }){
Get-MessageTrackingLog -Sender $x -Server MYHUBTRANSPORT -EventID RECEIVE -Start "7/1/2010 12:00am" -End "7/31/2010 11:59pm" |ft Sender,TimeStamp,TotalBytes,RecipientCount -autosize
}


thank you
0
Comment
Question by:cyberleo2000
  • 5
  • 3
  • 2
10 Comments
 
LVL 12

Expert Comment

by:Gary Dewrell
ID: 33501086
Take a look at this. Might be more than you wanted but it does provide the result you are looking for.

http://msexchangeteam.com/archive/2008/02/07/448082.aspx
0
 
LVL 13

Expert Comment

by:soostibi
ID: 33501522
What about this? (It is just counting all mail went through the HUB, I did not filter by originating mailbox server.)
Get-MessageTrackingLog -Start 2010.08.19 -end 2010.08.23 -EventId receive -ResultSize unlimited | 

	?{$_.source -eq "storedriver"} | Group-Object sender -NoElement

Open in new window

0
 

Author Comment

by:cyberleo2000
ID: 33503561
Thanks soostibi, I totally forgot about the group-Object cmdlet. two questions through, why would you need ?{$_.source -eq "storedriver"}, isn't the fact that your searching for eventid recevie enough? Also, what exactly does "?" at the begining of that line do? is it just a standin for "where"

thanks
0
 

Author Comment

by:cyberleo2000
ID: 33503779
I answered my own question. Without the stordriver search the command returns all messages received by the hub, event external ones. One last question, the output cuts off, as shown below, how can I format the output?

Count Name                    
----- ----                    
  791 MOMAlerts@lendlease.com  
  713 MicrosoftExchange329e7...
  502 imapemeaprod@lendlease...
  433 globalportaladmin@lend...
  226 apoprd@lendlease.com    
  202 root@lendlease.com      
0
 
LVL 12

Expert Comment

by:Gary Dewrell
ID: 33504040
Add ft -autosize to the end.
0
 
LVL 13

Expert Comment

by:soostibi
ID: 33504057
? is the alias for Where-object cmdlet.
You can format the output by format-table. With a hashtable structure you can set the column name (n="..."), the data expression (e={...}), the alignment (a="left"), and the column width (w=70).
0
 
LVL 13

Accepted Solution

by:
soostibi earned 500 total points
ID: 33504066
The code disappeared.
Get-MessageTrackingLog -Start 2010.08.19 -end 2010.08.23 -EventId receive -ResultSize unlimited | 

	?{$_.source -eq "storedriver"} | Group-Object sender -NoElement | 

		Format-Table @{n="message count"; e={$_.count};a="left"; w=20}, @{n="from address"; e={$_.name}; w=70}

Open in new window

0
 
LVL 13

Expert Comment

by:soostibi
ID: 33504091
The -autosize has a disadvantage: is you use it, format-table will wait for all the results, calculates the optimal column widths and then outputs the results. With the "manual" hash table formatting as an output borns, it will be emitted to the screen at once.
0
 

Author Closing Comment

by:cyberleo2000
ID: 33504780
Thank you for all your help. Note: exchange management shell did not accept n as a key in format-table, although it did accept l for label. thanks again.
0
 
LVL 13

Expert Comment

by:soostibi
ID: 33505053
Actually PowerShell 1.0 does not accept "n", PowerShell 2.0 does.
0

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Synchronize a new Active Directory domain with an existing Office 365 tenant
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates‚Ķ
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

757 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