Hi Readers,
Today I am sharing a script that reads list of users from CSV file & extract message tracking logs based on the dates mentioned in CSV.
Here is the example CSV file:
& here are the results in log folder that will be received after script execution
Download & extract the zip file from link provided, populate the csv file & run the batch , below will be the output on the screen.
https://github.com/VikasSukhija/Downloads/blob/master/Tracking.zip
###################################################################################### # # Author: Vikas Sukhija # Description: Message Tracking Multiple users from CSV # based on diffrent dates # Date:- 08/02/2014 ###################################################################################### If ((Get-PSSnapin | where {$_.Name -match "Microsoft.Exchange.Management.PowerShell.E2010"}) -eq $null) { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 } $data = import-csv .\Trackingfile.csv foreach ($i in $data) { $userid = $i.NetworkID $start = $i.TERM_EFFECTIVE_DATE $end = $i.Trackingtilldate $sender = $i.Sender $csv = ".\logs" + "\" + $userid + "_.csv" @" $userid $start $end $sender "@ Write-host "Message Tracking started for ------------------------$userid" -foregroundcolor Green Get-transportserver | Get-MessageTrackingLog -Start $start -End $end -sender $sender –resultsize unlimited | select Timestamp,clientip,ClientHostname, ServerIp,ServerHostname,sender,EventId, MessageSubject, TotalBytes , SourceContext,ConnectorId, Source ,@{Name=”Recipents”;Expression={$_.recipients}} | export-csv $csv } ######################################################################################
Tech Wizard
Hi Vikas,
Thank you so much. You saved my lots of time.
Excellent job. Script is perfect.