Link to home
Start Free TrialLog in
Avatar of Travis Hahn
Travis HahnFlag for United States of America

asked on

Exchange 2010 Email Stats Script - not showing all mailboxes

I have used a script from Microsoft's Script Repository called Email Stats.  It gets stats on emails received and sent.  However we have noticed that it is not including all mailboxes.

I was looking for one of the great EE Experts to review the script and see if there is something that I am overlooking that would bypass some mailboxes.

I have attached the script
Avatar of SubSun
SubSun
Flag of India image

Would you mind posting the link to the script which you are referring too?
Avatar of Travis Hahn

ASKER

Sorry - I tried uploading the .ps1 file and I didnt notice that it wouldnt upload

I have attached it now
es.txt
The script collects information from the message tracking logs from the previous day. So if a recipient didn’t sent or receive mail on that day then they will not appear in report..
I know that part but - they did recieve email - I logged in and checked
These are the code lines from the Script...
$today = get-date
$rundate = $($today.adddays(-1)).toshortdatestring()
get-messagetrackinglog -Server $ht -Start "$rundate" -End "$rundate 11:59:59 PM" -resultsize unlimited 

Open in new window

So if you run it today then it will search from 9/10/2013 to 9/10/2013 11:59:59 PM (Server time). If user have sent or receive mail with in this time frame then only it will display.. Other than that I am not seeing any possible reason..

You may run get-messagetrackinglog against the user at this time frame and see the result..
I have attached a copy of the my get-messagetrackinglog against the user RMA and you can see they got mail yesterday
emaes.PNG
What if you try..
$today = get-date
$rundate = $($today.adddays(-1)).toshortdatestring()
get-messagetrackinglog -Recipients rma@domain.com -Start "$rundate" -End "$rundate 11:59:59 PM" -resultsize unlimited

Open in new window


If above output the user information.. then just run the script ad see if you get same result..
I got the same result
Sorry.. I don't have any further suggestions..
Okay - thank you.  How about changing my script to give me 7 days instead of 1 day stats?
Chnage $rundate = $($today.adddays(-1)).toshortdatestring()

to $rundate = $($today.adddays(-7)).toshortdatestring()

and following line
get-messagetrackinglog -Server $ht -Start "$rundate" -End "$rundate 11:59:59 PM" -resultsize unlimited |

Open in new window

to
Get-messagetrackinglog -Server $ht -Start "$rundate" -End "$((Get-date).adddays(-1).toshortdatestring()) 11:59:59 PM" -resultsize unlimited |

Open in new window

That only produced for September 5th - it went back 7 days but didn’t accumulate the data
Did you change the Get-messagetrackinglog line?
	Get-messagetrackinglog -Server $ht -Start "$rundate" -End "$((Get-date).adddays(-1).toshortdatestring()) 11:59:59 PM" -resultsize unlimited |
	time_pipeline |%{

Open in new window

Is it still showing 24 hours data?
Holy Crap - sorry No it is doing a weekly total - however the Date on Column A is getting set to 7 days ago, and the the File name is appending to 7 days ago.

Is there a way I can get those to change?
To change the file name to current date..

change $outfile_date = ([datetime]$rundate).tostring("yyyy_MM_dd")

to

$outfile_date = (Get-date).tostring("yyyy_MM_dd")


however the Date on Column A is getting set to 7
Which date column you referring to? can you post a screenshot?
On the output to CSV the date is = to rundate

$obj_table = {
@"
Date = $rundate
User = $($address.split("@")[0])
Domain = $($address.split("@")[1])
Sent Total = $(0 + $total_msgsent[$address])
#Sent MB Total = $("{0:F2}" -f $($total_bytessent[$address]/1mb))
Received Total = $(0 + $msgrec[$address])
#Received MB Total = $("{0:F2}" -f $($bytesrec[$address]/1mb))
Sent Internal = $(0 + $total_msgsent_exch[$address])
#Sent Internal MB = $("{0:F2}" -f $($total_bytessent_exch[$address]/1mb))
Sent External = $(0 + $total_msgsent_smtpext[$address])
#Sent External MB = $("{0:F2}" -f $($total_bytessent_smtpext[$address]/1mb))
Received Internal = $(0 + $msgrec_exch[$address])
#Received Internal MB = $("{0:F2}" -f $($bytesrec_exch[$address]/1mb))
Received External = $(0 + $msgrec_smtpext[$address])
#Received External MB = $("{0:F2}" -f $($bytesrec_smtpext[$address]/1mb))
#Sent Unique Total = $(0 + $unique_msgsent[$address])
#Sent Unique MB Total = $("{0:F2}" -f $($unique_bytessent[$address]/1mb))
#Sent Internal Unique  = $(0 + $unique_msgsent_exch[$address]) 
#Sent Internal Unique MB = $("{0:F2}" -f $($unique_bytessent_exch[$address]/1mb))
#Sent External  Unique = $(0 + $unique_msgsent_smtpext[$address])
#Sent External Unique MB = $("{0:F2}" -f $($unique_bytessent_smtpext[$address]/1mb))
"@
}

Open in new window

CaptureScriptdate.PNG
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am all Good - Thank you very Much
Awesome