在Office 365中,是否可以导出SMTP日志?也许在powershell或任何其他方式.
我的目标是全面了解从特定域发送和发送到特定域的所有消息.
最佳答案
通过组合在线找到的2个脚本,我设法弄明白了.
这是完成这项工作的脚本.
#Accept input parameters
Param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[string] $Office365Username,
[Parameter(Position=1, Mandatory=$true, ValueFromPipeline=$true)]
[string] $Office365Password
)
$OutputFile = "DetailedMessageStats.csv"
Write-Host "Connecting to Office 365 as $Office365Username..."
#Connect to Office 365
$SecurePassword = $Office365Password | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Office365Username, $SecurePassword
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $session -AllowClobber
Write-Host "Collecting Recipients..."
#Collect all recipients from Office 365
$Recipients = Get-Recipient -ResultSize Unlimited | select PrimarySMTPAddress
$MailTraffic = @{}
foreach($Recipient in $Recipients)
{
$MailTraffic[$Recipient.PrimarySMTPAddress.ToLower()] = @{}
}
$Recipients = $null
#Collect Message Tracking Logs (These are broken into "pages" in Office 365 so we need to collect them all with a loop)
$Messages = $null
$Page = 1
do
{
Write-Host "Collecting Message Tracking - Page $Page..."
$CurrMessages = Get-MessageTrace -StartDate (Get-Date).AddDays(-7) -EndDate (Get-Date) -PageSize 5000 -Page $Page| Select Received,*Address,*IP,Subject,Status,Size
if ($CurrMessages -ne $null)
{
$CurrMessages | Export-Csv C:\FILE-$PAGE.csv -NoTypeInformation
}
$Page++
$Messages += $CurrMessages
}
until ($CurrMessages -eq $null)
Remove-PSSession $session
相关文章
- powershell - 如何在交换混合环境中备份/导出office 365电子邮件到pst?
- Office 365 Exchange客户端连接日志
- 尝试通过Office 365发送电子邮件时出现c# - SMTP 5.7.57错误
- powershell - Office 365 cmdlet的参数错误
- active-directory - OU使用PowerShell批量许可Office 365用户
- c# - Office 365 SMTP开始触发net_io_connectionclosed
- microsoft-office-365 - Office 365 - 如何获取每个用户的Office安装报告?
- microsoft-office-365 - 可以在Office 365中恢复已删除项目的整个邮箱吗?