Convert the message-tracking script output to HTML

krish5music
krish5music used Ask the Experts™
on
Hello Team,

I have the below scripts which will provide me the details of emails which are blocked by transport rules. Can you please help me to get the report in HTML format ?

(Get-TransportService) | Get-MessageTrackingLog -ResultSize Unlimited -Start (Get-Date).AddHours(-168) | Wh
ere {$_.EventID -eq"FAIL"-OR$_.EventID -eq"DSN"} | ForEach {Get-MessageTrackingLog -ResultSize Unlimited -MessageID $_.M
essageID -Start (Get-Date).AddHours(-168) | ? {$_.EventID -notlike"HA*"-and$_.EventID -ne"PROCESSMEETINGMESSAGE"-and$_.E
ventID -ne"NOTIFYMAPI"} | Select Timestamp, EventId, Source, Sender, {$_.Recipients}, {$_.RecipientStatus}, MessageSubje
ct, TotalBytes, RecipientCount, MessageId, ClientIp, ClientHostname, OriginalClientIp, ServerIp, ServerHostname, Message
Info, MessageLatency, MessageLatencyType, {$_.EventData}, SourceContext, ConnectorId}

Thanks
Krish
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
All you should need is pipe the output to ConvertTo-Html and write it to a file:
(Get-TransportService) |
	Get-MessageTrackingLog -ResultSize Unlimited -Start (Get-Date).AddHours(-168) |
	Where {$_.EventID -eq "FAIL" -OR $_.EventID -eq "DSN"} | 
	ForEach-Object {
		Get-MessageTrackingLog -ResultSize Unlimited -MessageID $_.MessageID -Start (Get-Date).AddHours(-168) | 
			Where-Object {$_.EventID -notlike "HA*" -and $_.EventID -ne "PROCESSMEETINGMESSAGE" -and $_.EventID -ne "NOTIFYMAPI"} |
			Select-Object -Property Timestamp, EventId, Source, Sender, {$_.Recipients}, {$_.RecipientStatus}, MessageSubject, TotalBytes, RecipientCount, MessageId, ClientIp, ClientHostname, OriginalClientIp, ServerIp, ServerHostname, MessageInfo, MessageLatency, MessageLatencyType, {$_.EventData}, SourceContext, ConnectorId
	} | ConvertTo-Html | Set-Content -Path C:\Temp\report.html

Open in new window

Author

Commented:
Hello OBDA,

Thanks for your email.  I was trying to findout if it possible to pull the information on which rule gets applied for each email failure.

I have two rules setup , one for credit card and SSN, another one for Driver license. On my script i posted above, i can able to pull only Failure attempt and DSN message, However it doesn't tells me which rules applied for each failure attempt.

It would be a great help, if you can help me with this.

Thanks
Krish
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:

pull the information on which rule gets applied for each email failure.
Sorry, I know a lot about of Windows, AD, PowerShell, and the like, but I'm not an Exchange administrator. You should probably post a new question with a matching title for that.

Author

Commented:
No issues ObdA. I appreciate your assistance. Also i have posted a new question. Its all about combination of condition. in Message  It woud be great if you can have look at it.

Thanks
Krish

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial