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
Travis HahnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SubsunCommented:
Would you mind posting the link to the script which you are referring too?
0
Travis HahnAuthor Commented:
Sorry - I tried uploading the .ps1 file and I didnt notice that it wouldnt upload

I have attached it now
es.txt
0
SubsunCommented:
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..
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Travis HahnAuthor Commented:
I know that part but - they did recieve email - I logged in and checked
0
SubsunCommented:
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..
0
Travis HahnAuthor Commented:
I have attached a copy of the my get-messagetrackinglog against the user RMA and you can see they got mail yesterday
emaes.PNG
0
SubsunCommented:
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..
0
Travis HahnAuthor Commented:
I got the same result
0
SubsunCommented:
Sorry.. I don't have any further suggestions..
0
Travis HahnAuthor Commented:
Okay - thank you.  How about changing my script to give me 7 days instead of 1 day stats?
0
SubsunCommented:
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

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

Open in new window

0
SubsunCommented:
Is it still showing 24 hours data?
0
Travis HahnAuthor Commented:
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?
0
SubsunCommented:
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?
0
Travis HahnAuthor Commented:
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
0
SubsunCommented:
Try Date = $today.toshortdatestring() instead of Date = $rundate

Or change to
Date = "$rundate to $((Get-date).adddays(-1).toshortdatestring())"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Travis HahnAuthor Commented:
I am all Good - Thank you very Much
0
Travis HahnAuthor Commented:
Awesome
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.