Asked by:
How to view users daily incoming and outgoing mails

General discussion
-
Hi all,
Can I see users daily total incoming and outgoing mail count and size in power shell?
Example;
User Incoming Count/Size Outgoing Count/Size
User1----------- 1500 / 150 Mb-----------750 / 50 Mb
USer2------------700 / 50 Mb-------------550 / 70 Mb
thanks in advance
Friday, October 19, 2012 8:21 AM
All replies
-
Hi mscik,
We can use EMS to check the daily or some days total incoming and outgoing mails information.
=====
Incoming mails :
Type the command below into EMS:
Get-MessageTrackingLog -Server "<Your Trasport Server Name>" -EventID "RECEIVE" -Start "10/19/2012 00:00:00 AM" -End "10/19/2012 12:00:00 PM" | fl Recipients,EventID,TotalBytes
=====
Outcoming mails:
Type the command below into EMS:
Get-MessageTrackingLog -Server "<Your Trasport Server Name>" -EventID "Send" -Start "10/19/2012 12:00:00 AM" -End "10/19/2012 12:00:00 PM" | fl Recipients,EventID,TotalBytes
=====
Also I suggest you to use the tool in EMC to check them if possible, because that may be easier.
Open EMC --> Click "Toolbox" --> Click "Tracking Log Explorer"
And then we can check all mails based on the various conditions which you will select.
=====
Hope all these helpful to you.
If anything is unclear, please feel free to let me know.
Have a nice weekend!
Regards,
Jerry Ye
Exchange 2010 | Exchange 2007 | Outlook 2010 | Outlook 2007 | SBS 2008
Finding problems is to make progress & Solving problems is to keep advance
- Edited by Jerry__Ye Friday, October 19, 2012 9:59 AM
Friday, October 19, 2012 9:58 AM -
Hi Jerry
thanks alot for your mail, but result of this command like that,can't we collect in one row ?
Recipients : {user1@contoso.com}
EventId : RECEIVE
TotalBytes : 28867Recipients : {user1@contoso.com}
EventId : RECEIVE
TotalBytes : 28860Recipients : {user1@contoso.com}
EventId : RECEIVE
TotalBytes : 3067Recipients : {user1@contoso.com}
EventId : RECEIVE
TotalBytes : 43105Recipients : {user1@contoso.com}
EventId : RECEIVE
TotalBytes : 28759Friday, October 19, 2012 11:33 AM -
Tried this?
http://gallery.technet.microsoft.com/exchange/bb94b422-eb9e-4c53-a454-f7da6ddfb5d6
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Friday, October 19, 2012 11:43 AM -
I tried this but it always shows me just previous days report, I can't change start and end date in this script,can you edit script in order to I can change day by day ?
Friday, October 19, 2012 1:03 PM -
You can change the start and end date. There's comments in the discussion about doing that.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Friday, October 19, 2012 1:10 PM -
sorry but I couldn't run report after I changed command,can you change this please example: 10/18/2012-10/19/2012
get-messagetrackinglog -Server $ht -Start "$rundate" -End "$rundate 11:59:59 PM" -resultsize unlimited |
Friday, October 19, 2012 1:28 PM -
you have to change this line:
$rundate = $($today.adddays(-1)).toshortdatestring()
to 7 if you want to check logs from last week:
$rundate = $($today.adddays(-7)).toshortdatestring()
you can change script inside to run it with a date as a parameter.
Friday, October 19, 2012 1:32 PM -
ohh sorry ,it done now,thank you so much for your help,
Friday, October 19, 2012 1:49 PM -
I have a long list of changes that people have requested to be added to that script. I just haven't had time to re-write it.....
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Friday, October 19, 2012 1:51 PM -
its very useful for people if you share them I will appreciate you ,I'm looking for your shares :)
Friday, October 19, 2012 3:14 PM -
also can I define report between two date ?example ; 09/01/212 - 10/01/2012Friday, October 19, 2012 3:20 PM
-
That's on the list. The problems is needing to write it so that it will scale. For some Exchange orgs, reading thorugh a month's worth of log files at a time is relatively trivial. For other's it would be a very long process.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Friday, October 19, 2012 3:26 PM -
thank you I understand you very well I wish I would help you in this issue , anyway my other question is that, can I define between 2 date for report ?Friday, October 19, 2012 7:33 PM
-
Hi
to run this script with defining two dates for report you have to:
change this line:
get-messagetrackinglog -Server $ht -Start "$rundate" -End "$rundate 11:59:59 PM" -resultsize
to
get-messagetrackinglog -Server $ht -Start "$start_date" -End "$end_date" -resultsize
and in the beginning of this script after:
#requires -version 2.0 $today = get-date $rundate = $($today.adddays(-1)).toshortdatestring()
write:
$start_date = "2012-10-05 8:00:00 AM"
$end_date = "2012-10-15 11:59:59 PM"
I think it should work.
You can have problem with date format and correct format you can check running:(get-date).toshortdatestring()
Remigiusz
Friday, October 19, 2012 7:58 PM -
it wasn't recognized by system unfortunataly,can anyone help me?
Saturday, October 20, 2012 9:11 PM -
also even if I change this value it always gets before day :(
$rundate = $($today.adddays(-30)).toshortdatestring()
Saturday, October 20, 2012 9:48 PM -
At line 101, replace this line:
get-messagetrackinglog -Server $ht -Start "$rundate" -End "$rundate 11:59:59 PM" -resultsize unlimited |
With:
get-messagetrackinglog -Server $ht -Start $Start_ -End $End_ -resultsize unlimited |
Then add these 2 lines:
$Start_ = 'mm/dd/yyyy hh:mm:ss' $End_ = 'mm/dd/yyyy hh:mm:ss'
at line 5, right below the #Requires statement.
Put your start and end time strings in those variables.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
- Edited by mjolinor Sunday, October 21, 2012 12:40 AM
Sunday, October 21, 2012 12:40 AM -
Sorry but I couldn't run it ,I think I did some mistake When I change script,can you check it please ?
#mjolinor
#02/24/2011#requires -version 2.0
$Start_ = '10/10/2012 00:00:00'
$End_ = '10/15/2012 23:59:59'$today = get-date
$rundate = $($today.adddays(-1)).toshortdatestring()$outfile_date = ([datetime]$rundate).tostring("yyyy_MM_dd")
$outfile = "email_stats_" + $outfile_date + ".csv"$dl_stat_file = "DL_stats.csv"
$accepted_domains = Get-AcceptedDomain |% {$_.domainname.domain}
[regex]$dom_rgx = "`(?i)(?:" + (($accepted_domains |% {"@" + [regex]::escape($_)}) -join "|") + ")$"$mbx_servers = Get-ExchangeServer |? {$_.serverrole -match "Mailbox"}|% {$_.fqdn}
[regex]$mbx_rgx = "`(?i)(?:" + (($mbx_servers |% {"@" + [regex]::escape($_)}) -join "|") + ")\>$"Monday, October 22, 2012 5:50 AM -
any news? :(Monday, October 22, 2012 3:36 PM
-
I see where you've added the variables at the top to the script. Did you change the get-messagetrackinglog command at line 101 to use those variables?
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Monday, October 22, 2012 3:38 PM -
yes I cahnged like this,
get-messagetrackinglog -Server $ht -Start $Start_ -End $End_ -resultsize unlimited |
Monday, October 22, 2012 6:49 PM -
I can't expain that, and cannot begin to diagnose it with nothing more to go on than "I could not run it".
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Monday, October 22, 2012 6:55 PM -
you need to change like this:
get-messagetrackinglog -Server $ht -Start '$Start_' -End '$End_' -resultsize unlimited |
Monday, October 22, 2012 7:31 PM -
That's going to make it try to use the literal strings '$Start_' and '$End_' as the arguments to the -Start and -End parameters......
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Monday, October 22, 2012 9:55 PM -
can you please write correct script for me ?Tuesday, October 23, 2012 7:06 PM
-
That's a can of worms I'd rather not open up on a public forum.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Tuesday, October 23, 2012 8:20 PM -
can you send mail to mscik@outlook.com please ?Wednesday, October 24, 2012 12:48 PM
-
Outlook.com? Are you trying to use this script in a hosted Exchange environment?
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Wednesday, October 24, 2012 1:02 PM -
yes outlook.com,its new hotmail :)Wednesday, October 24, 2012 1:17 PM
-
It's also cloud-based, which means you can't use get-messagetrackinglog. The salesman might have told you "it's just like having your own Exchange server", but it's not.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
- Edited by mjolinor Wednesday, October 24, 2012 1:32 PM
Wednesday, October 24, 2012 1:30 PM