Help with Message Count script
Hello, I am trying to write a script which will take find the number of messages sent from a list of senders to our cars.org domain. Ideally I would be able to search all our hub servers and get a count of messages from each sender. What I have so far is: $hub = get-transportserver $inc=import-csv c:\usersmtp.csv foreach ($in in $inc){{{Get-MessageTrackingLog -Server $hub -Sender $in|where {[string]$_.Recipients -like "*@cars.org"} -St art 3/17/2011 -End 3/18/2011 -ResultSize unlimited}}} unfortunately I get an error from $hub and this output only outputs {Get-MessageTrackingLog -Server $hub -Sender $in|where {[string]$_.Recipients -like "*@cars.org"} -St art 3/17/2011 -End 3/18/2011 -ResultSize unlimited} Lastly, how could I use .count to count the # of messages from each sender? Thanks Any help would be appreciated. Thanks
March 18th, 2011 4:15pm

Instead of "{[string]$_.Recipients -like "*@cars.org"}", I think you really want "{$_.EventID -eq "RECEIVE"}" because you want everything that's inbound to the Exchange server, right? Or do you relay mail from non-Exchange sources? If so, you might want to -and both clauses together. It looks like you have the -Start, -End and -ResultSize on the wrong side of the pipeline. So, I think this is what you want. (ForEach ($in in $inc) {{{Get-MessageTrackingLog -Server $hub -Sender $in -Start 3/17/2011 -End 3/18/2011 -ResultSize Unlimited | Where {$_.EventID -eq "RECEIVE"}}}}).count I tested this and it seems to work on my test server, but it doesn't have much in the message tracking logs.Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Free Windows Admin Tool Kit Click here and download it now
March 18th, 2011 5:22pm

Hi Ed, Thanks but I receive a message: Unexpected token 'in' in expression or statement. Also, since cars.org is just one of our domains, how could I break this down to find all messages sent from a list of users to a DL, admins@cars.org? Thanks for your help, Robert
March 22nd, 2011 8:50pm

That message suggests to me that you made a typo and entered "in" instead of "$in" somewhere. You would have to enumerate the membership of admins@cars.org and pipe the result into a ForEach.Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Free Windows Admin Tool Kit Click here and download it now
March 23rd, 2011 12:03pm

Hi Ed, I received the error when I cut and pasted your code above. $inc=get-content c:\usersmtp.txt (or $inc=import-csv c:\users.csv) $hub = "hubserver.domain.com" (ForEach ($in in $inc) {{{Get-MessageTrackingLog -Server $hub -Sender $in -Start 3/17/2011 -End 3/18/2011 -ResultSize Unlimited | Where {$_.EventID -eq "RECEIVE"}}}}).count Thanks, Robert
March 23rd, 2011 12:37pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics