Powershell Script to find the number of sent messages users have sent

Hi,

Can you please help me with this request. I need a powershell script to find the number of sent messages certain customers have sent since May 1st. A manager in a department has requested this information. So if a users has sent 200 messages it will need to be reflected in the report. I'm guessing either csv or html or both. There are about 30 users.

***Update***

Sorry forgot to mention that it's an Exchange Server 2010 environment and the report will also need to show the users alias, first and last name if possible.
makel2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Will SzymkowskiSenior Solution ArchitectCommented:
try the following...
$StartDate = "05/01/2015"
$Server = "cas.domain.com"
$Users = import-csv "c:\filename.csv"
ForEach ($User in $Users) {
$User.EmailAddress
        
        Get-MessageTrackingLog -Server $Server -Start $StartDate -Sender $User.EmailAddress | measure | 
        Select $User.EmailAddress, Count |
        Export-Csv "c:\EmailCount.csv" -nti -append

}

Open in new window


Will.

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
makel2Author Commented:
Is it possible the script can be updated to reflect specific users and specific SMTP domain name.
Will SzymkowskiSenior Solution ArchitectCommented:
Sure not a problem.

Will.
SD-WAN: Making It Work for You

As bandwidth requirements and Internet costs grow, businesses naturally want to manage budgets by reducing reliance on their most expensive connection types. Learn more about how to make SD-WAN work for your business in our on-demand webinar!

makel2Author Commented:
Any chance you can update it so :-)
Will SzymkowskiSenior Solution ArchitectCommented:
Here you go...
$StartDate = "05/01/2015"
$Recipient = "*@externaldomain.com"
$Server = "cas.domain.com"
$Users = import-csv "c:\filename.csv"
ForEach ($User in $Users) {
$User.EmailAddress
        
        Get-MessageTrackingLog -Server $Server -Start $StartDate -Sender $User.EmailAddress -Recipient $Recipient | measure | 
        Select $User.EmailAddress, Count |
        Export-Csv "c:\EmailCount.csv" -nti -append

}

Open in new window


I have add the variable $Recipient on line 2. Just change that to the smtp domain you want to search.

You also need to make sure that your csv file has Emailaddress as a column heading, and then all of the users in a separate cell below it.

Will.
makel2Author Commented:
That did the trick, thanks
Will SzymkowskiSenior Solution ArchitectCommented:
Excellent!

Glad that i could help.

Will.
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
Microsoft Server OS

From novice to tech pro — start learning today.