Friday 13 March 2015

Message Tracking Log for Distribution Group

Are you wondering how to take the transaction logs for distribution group?

I have written an exchange powershell to take the logs of distribution group which are receiving the mails from external network. We need to specify the event id as Expand as mentioned in the below script.

When you run Get-MessageTrackingLog on the hub server you could pull only the logs which are being sent the server where you are going to run this tracking log cmdlet.

To get an accurate log report we should pull the transaction logs from all the hub transport server installed in the organisation

How do you pull the tracking logs if you have multiple hub transport server?

$Servers = Get-ExchangeServer | where { $_.isHubTransportServer -eq $true -or $_.isMailboxServer -eq $true }

We are saving all the hub server details in the $server variable to get the logs from all the hub server installed in the organization

You just wanted to change the start date and end date based on the requirement. if you wanted to pull the logs for last 15 days you need to align with start and date in the below script.


###############Get-Messagetrackinglog from all installed hub servers######################

$Servers = Get-ExchangeServer | where { $_.isHubTransportServer -eq $true -or $_.isMailboxServer -eq $true }

$report = @()

try {

$logs = $servers | ForEach-Object { Get-MessageTrackingLog -EA SilentlyContinue -ResultSize Unlimited -Server $_.Name -Start (Get-Date).AddDays(-30) -End (Get-Date) -EventID Expand | select sender, RelatedRecipientAddress}


foreach ($log in $logs)
{

$MSGSender = $log.Sender
$DG = $log.RelatedRecipientAddress


$Obj = New-Object PSObject
$Obj | Add-Member -MemberType NoteProperty -Name "Sender" -Value $MSGSender
$Obj | Add-Member -MemberType NoteProperty  -Name"DistributionGroup" -Value $DG
$report += $Obj

}

} catch {

} finally {

$report | Export-Csv  C:\Users\sankar\Desktop\DG-MessageTracking.CSV

$report | Out-GridView
}

#####################################################################

No comments:

Post a Comment