script to count all email received for 50 mailbox on exchange 2013

hello,

i need a powershell script to get mailbox from csv file like this one:

mailbox1@domain.com
mailbox2@domain.com
mailbox3@domain.com
.....

and get for each one the number of email received last 3 month.

all my server are exchange 2013.

thanks
cawasakiAsked:
Who is Participating?
 
Will SzymkowskiSenior Solution ArchitectCommented:
When you use the "measure" command in powershell, it does not have any other attributes to like Displayname or Email address. If you want to export to a CSV use the following command, i have modified the original one.

$Date = get-date
$Mailboxes = import-csv "c:\filename.csv"
ForEach ($User in $Mailboxes) {
$User.Mailbox
Get-MessageTrackingLog -Server <CASserver> -Start $Date.AddDays(-90) -Recipient $User.Mailbox |
Export-Csv "c:\Results.csv" -nti
}          

Open in new window


Will.
0
 
cawasakiAuthor Commented:
hello Amit,

how i can apply this for 100 emails address?
0
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

 
Will SzymkowskiSenior Solution ArchitectCommented:
Use the following script below...
Make sure that your csv heading is Mailbox, then use the code below.
$Date = get-date
$Mailboxes = import-csv "c:\filename.csv"
ForEach ($User in $Mailboxes) {
$User.Mailbox
Get-MessageTrackingLog -Server <CASserver> -Start $Date.AddDays(-7) -Sender $User.Mailbox | measure
}

Open in new window


This will simply get the Count of all messages that were sent from each user that is in your csv file.

Will.
0
 
cawasakiAuthor Commented:
Hello

What i need is count email received on this mailbox not sent

Thanks
0
 
Will SzymkowskiSenior Solution ArchitectCommented:
Ahh sorry about that, been a long day. I have modified my original script to accommodate your requirements.

$Date = get-date
$Mailboxes = import-csv "c:\filename.csv"
ForEach ($User in $Mailboxes) {
$User.Mailbox
Get-MessageTrackingLog -Server <CASserver> -Start $Date.AddDays(-90) -Recipient $User.Mailbox | measure
}          

Open in new window


Just remember that if your message tracking logs are not set to 3 months back you will only be able to go back as far as what the transport settings are set to. By default it is 30 days.

Will.
0
 
cawasakiAuthor Commented:
hello,

i need to test this to be sure that the number of email i get from this script is the good number of only mail received and not sent & received.

it possible to get csv file result with mailbow and number like this:

test@domain.com,50
......

thanks
0
 
cawasakiAuthor Commented:
i have test the script with -Start $Date.AddDays(-1) to get all email received to day but the number is not good, i have received more 20 email and the script show 11
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.