【O365 PowerShell Script】邮件跟踪报告
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了【O365 PowerShell Script】邮件跟踪报告,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2153字,纯文字阅读大概需要4分钟。
内容图文
![【O365 PowerShell Script】邮件跟踪报告](/upload/InfoBanner/zyjiaocheng/1150/96ce149cae194847bd2504eadbf42352.jpg)
#1.一种为快速报告(导出没有延迟),对应命令为get-messagetrace及get-messagetracedetail
#2.第二种为延迟细节报告(一般有1小时延迟,但是会更加细节),对应命令为get-historicalsearch
#以下脚本可以使用PowerShell导出比较直观的快速报告,和GUI相似,适合服务器运维定期导出报告使用
#O365 There are two types of mail tracking reports:
#1. One is for quick reports (no delay in export), and the corresponding commands are get-messagetrace and get-messagetracedetail
#2. The second type is the delayed detail report (usually there is a 1 hour delay, but it will be more detailed), and the corresponding command is get-historicalsearch
#The following script can use PowerShell to export more intuitive and fast reports, similar to GUI, suitable for server operation and maintenance to export reports regularly
#The below part needs to be modified
#以下部分需要更改
$startdate = 07/25/2020
$endDate = 07/26/2020
$CSV = "C:\Users\tonylin\AppData\Local\Microsoft\Outlook\test.csv"
#===============================================================================
#No need to modify below parts
#以下部分无需更改
$results = @()
$page = 1
While (get-messagetrace -StartDate $startdate -EndDate $endDate -pagesize 5000 -page $page)
{
$MessageTrace = get-messagetrace -StartDate $startdate -EndDate $endDate -pagesize 5000 -page $page
$page++
foreach($Trace in $MessageTrace)
{
$MessageDetail = get-messagetracedetail -MessageTraceId $Trace.messagetraceid.guid -recipientaddress $trace.recipientaddress
foreach($detail in $MessageDetail)
{
$data = (($detail.data).split("/><") | where-object {$_ -like "*return*"})
if($data)
{
$return_path = $data.split(‘"‘)[3]
if($return_path -eq "<>")
{
$return_path = "<>"
}
}else{
$return_path = ""
}
$results += New-Object PSObject -property @{
MessageId = $detail.messageid
Date = $detail.Date
Event = $detail.Event
Action = $detail.Action
Detail = $detail.Detail
Data = $detail.Data
SenderAddress = $Trace.senderaddress
RecipientAddress = $Trace.RecipientAddress
ReturnPath = $return_path
}
}
}
}
$results |select MessageId,Date,Event,Action,Detail,Data,SenderAddress,RecipientAddress,ReturnPath | export-csv $CSV -notypeinformation -encoding utf8
原文:https://blog.51cto.com/12954151/2516140
内容总结
以上是互联网集市为您收集整理的【O365 PowerShell Script】邮件跟踪报告全部内容,希望文章能够帮你解决【O365 PowerShell Script】邮件跟踪报告所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。