Solved

EXCHANGE 2007, SCRIPTS

Posted on 2016-09-19
67
70 Views
Last Modified: 2016-09-21
I need to run a script on EMS  to find number of email received and send by a particular group OR USERS
0
Comment
Question by:pramod1
  • 41
  • 25
67 Comments
 
LVL 41

Expert Comment

by:Amit
ID: 41805157
You can use messaging tracking logs. Parse them to retrieve the data. Make sure you have tracking logs available. Normally it is set to replace after 14 days. You can use EM tool or EMS both. Below is a script from MS.
https://gallery.technet.microsoft.com/scriptcenter/bb94b422-eb9e-4c53-a454-f7da6ddfb5d6
0
 

Author Comment

by:pramod1
ID: 41805177
confused, how to retrieve number of email send and received from 250 users
0
 

Author Comment

by:pramod1
ID: 41805205
can you provide some simple solution, I need to retrieve email sent and received by 250 users belonging to 1 group
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41805251
This should give you a count of email sent by each user in the group as requested
$Users = Get-DistributionGroupMember GroupName

foreach($user in $Users){
	Get-MessageTrackingLog  -ResultSize unlimited -Sender $user.PrimarySmtpAddress.ToString() -EventId Receive | where {$_.Source -eq "StoreDriver"} | Group-Object -Property sender | ft name,count
}		

Open in new window

0
 
LVL 49

Expert Comment

by:Akhater
ID: 41805282
wait ignore the above it is too slow

this should give the same but faster

$msgs = Get-MessageTrackingLog -ResultSize Unlimited -EventId Receive 
$out = @()

foreach($user in $users){

	$out += $msgs | ? {$_.sender -like $user.PrimarySmtpAddress  -and $_.source -eq "STOREDRIVER"} 

}

$out | Group-Object -Property sender | ft name,count

Open in new window

0
 

Author Comment

by:pramod1
ID: 41805447
we have group called storetablets which is universal distribution group and all users are inside there

can you incorporate that in script. will really help me
0
 

Author Comment

by:pramod1
ID: 41805456
how can I pipe them in txt I need to send
0
 
LVL 49

Accepted Solution

by:
Akhater earned 500 total points
ID: 41805488
$users = Get-DistributionGroupMember StoreTablets
$msgs = Get-MessageTrackingLog -ResultSize Unlimited -EventId Receive
$out = @()

foreach($user in $users){

      $out += $msgs | ? {$_.sender -like $user.PrimarySmtpAddress  -and $_.source -eq "STOREDRIVER"}

}

$out | Group-Object -Property sender | select name,count   | export-csv c:\list.csv
0
 

Author Comment

by:pramod1
ID: 41805490
-eq "STOREDRIVER"}  here I have to write " -eq "storetablet"}
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41805493
No I just updated the script for you
0
 

Author Comment

by:pramod1
ID: 41805497
so where it will members of storetablet group as all 250 users are in that group
0
 

Author Comment

by:pramod1
ID: 41805499
ok you wrote above , my bad
0
 

Author Comment

by:pramod1
ID: 41806418
Hi Akhater,

I am attaching screen shot, it is sitting like this for 10 mins, is it working , just to confirm
Capture1.JPG
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806536
You need to press enter to execute the last command and then check if the file was created
0
 

Author Comment

by:pramod1
ID: 41806645
file name got created with 0 bytes
0
 

Author Comment

by:pramod1
ID: 41806648
what have I missed
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806656
run the below and give me the output

$users = Get-DistributionGroupMember StoreTablets
$msgs = Get-MessageTrackingLog -ResultSize Unlimited -EventId Receive

$users.count
$msgs.count
0
 

Author Comment

by:pramod1
ID: 41806738
$users 497
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806743
what about $msgs
0
 

Author Comment

by:pramod1
ID: 41806757
it is still waiting
0
 

Author Comment

by:pramod1
ID: 41806763
what is your email address, I am logged into webex
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806767
I am sorry pramod like I told you in the message I can only connect thru the live connect of Experts-Exchange
0
 

Author Comment

by:pramod1
ID: 41806769
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806773
pramod1 this is a public forum please do not post such links it is not safe for you
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806785
any news about $msgs.count ?
0
 

Author Comment

by:pramod1
ID: 41806787
no it is still stuck
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806794
when you say stuck do you have a progress bar or anything ?
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806827
$msgs = Get-TransportServer | Get-MessageTrackingLog -ResultSize Unlimited -EventId Receive

$msgs.count
 

ok please try the above now and give me the output
0
 

Author Comment

by:pramod1
ID: 41806841
yes it is creating list.csv but with 0 bytes
0
 

Author Comment

by:pramod1
ID: 41806846
I am running on mailbox server should I run on CAS servr
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806848
you should run it on the transport server

anyway the command i gave you in my last post should work no matter where you run it please give it a try

also go to http://micc.mitel.com/kb/KnowledgebaseArticle51059.aspx and make sure message tracking log is enabled
0
 

Author Comment

by:pramod1
ID: 41806851
it seems working on cas server
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806873
Don't forget to press enter
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 49

Expert Comment

by:Akhater
ID: 41806874
Don't forget to press enter
0
 

Author Comment

by:pramod1
ID: 41806877
I did
0
 

Author Comment

by:pramod1
ID: 41806878
still showing progress bar
0
 

Author Comment

by:pramod1
ID: 41806880
I am running on exchange 2007
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806886
Progress bar is good wait for it to finish
0
 

Author Comment

by:pramod1
ID: 41806900
can you have a close look
Capture.JPG
0
 

Author Comment

by:pramod1
ID: 41806902
there are 2 symabols showing above progress bar
0
 

Author Comment

by:pramod1
ID: 41806907
$users = Get-DistributionGroupMember StoreTablets
 $msgs = Get-MessageTrackingLog -ResultSize Unlimited -EventId Receive
 $out = @()

 foreach($user in $users){

       $out += $msgs | ? {$_.sender -like $user.PrimarySmtpAddress  -and $_.source -eq "STOREDRIVER"}

 }

 $out | Group-Object -Property sender | select name,count   | export-csv c:\list.csv
0
 

Author Comment

by:pramod1
ID: 41806911
anything I am missing
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41806913
Did it create the file?
0
 

Author Comment

by:pramod1
ID: 41807045
on hub transport server, it didn't create the file
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41807058
In the same place where you ran the script just type
$msg.count
$out

What is the output
0
 

Author Comment

by:pramod1
ID: 41807109
nothing come
Capture.JPG
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41807116
no that's a new window you closed the old one ??

Ok
open a exchange shell windows and don't close it

run

$users =  Get-DistributionGroupMember StoreTablets
$msgs = Get-TransportServer |Get-MessageTrackingLog -ResultSize Unlimited -EventId Receive 
$out = @()

foreach($user in $users){

       $out += $msgs | ? {$_.sender -like $user.PrimarySmtpAddress  -and $_.source -eq "STOREDRIVER"} 

 }

Write-host $msgs.count
Write-host $out.count

$out | Group-Object -Property sender | select name,count   | export-csv c:\list.csv

Open in new window


give me the output and again don't close this shell
0
 

Author Comment

by:pramod1
ID: 41807128
I just needed number of emails received and sent by recipients in that group
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41807136
This expert suggested creating a Gigs project.
yes I know
0
 

Author Comment

by:pramod1
ID: 41807155
it is running
Capture.JPG
0
 

Author Comment

by:pramod1
ID: 41807156
let you know shortly
0
 

Author Comment

by:pramod1
ID: 41807161
it is held up here should I press enter
Capture.JPG
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41807164
no it is still running wait for it to finish
0
 

Author Comment

by:pramod1
ID: 41807167
I pressed enter it is still waiting with progress bar
0
 

Author Comment

by:pramod1
ID: 41807175
should I do again now as I pressed enter but it still shows status same with progress bar
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41807177
no just wait till it finishes and you have a prompt
0
 

Author Comment

by:pramod1
ID: 41807182
ok I will wait
0
 

Author Comment

by:pramod1
ID: 41807207
it is still sitting there the users I am referring to in that group has domain-retail.com can we modify anything
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41807225
It shouldn't be a still running send me a screen shot
0
 

Author Comment

by:pramod1
ID: 41807228
attached
Capture.JPG
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41807239
Ok maybe it is a huge list of emails give it some more time
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41807240
Ok maybe it is a huge list of emails give it some more time
0
 

Author Comment

by:pramod1
ID: 41807247
ok thanks I will let you know there are 250 users
0
 

Author Comment

by:pramod1
ID: 41807343
still showing the bar
0
 

Author Comment

by:pramod1
ID: 41807410
it is still showing bar , should I close it or leave it
0
 

Author Comment

by:pramod1
ID: 41807906
the script on the mailbox server creates the log file but empty , on CAS server script shows running for sometime but then progress bar comes up but no log file is created.

 we have resource domain set up like exchange is having disabled AD accounts and separate AD account forest, is that not causing issues
 
Exchange sits in another forest and AD account in another forest. Between both forest, we have tool like MIM, which replicates the data from primary AD forest to Exchange forest. MIM creates ID in Exchange forest as disabled.
0
 

Author Comment

by:pramod1
ID: 41809301
how can I check

number of emails flowing in and out of my organization through script

also how can I check public folders are mail enabled or not and how many
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now