如何设置每日报告,报告 24 小时内向组织外发送超过规定数量电子邮件的用户

如何设置每日报告,报告 24 小时内向组织外发送超过规定数量电子邮件的用户

我正在尝试创建一个脚本并在交换上安排它,以便为在 24 小时内向组织外发送超过规定数量的电子邮件的用户提供每日报告。

我找到了类似的脚本,但它与我尝试的场景不同。我也在使用 Exchange 2016:

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

$output = Get-TransportServer | Get-MessageTrackingLog -Start (get-date).AddDays(-1) -EventID "SEND" -ResultSize Unlimited | Group-Object -Property Sender | %{ New-Object psobject -Property @{Sender=$_.Name;Recipients=($_.Group | Measure-Object RecipientCount -Sum).Sum}} | Where-Object {$_.Recipients -gt 100} | Sort-Object -Descending Recipients | Format-Table -AutoSize Sender,Recipients | Out-String

Send-MailMessage -From [email protected] -Subject "Exchange senders report: $(Get-Date -UFormat '%a, %D')" -To [email protected] -Body $output -SMTP mail.example.com

答案1

请检查以下类似线程中的脚本是否对您有帮助:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
$output = Get-TransportServer | Get-MessageTrackingLog -Start (get-date).AddDays(-1) -ResultSize Unlimited | where{$ .EventId -eq "SEND" -or $.EventId -eq "SENDEXTERNAL" -and $ .Recipients -notlike "*@contoso.com*"}
$result = $output | Group-Object -Property Sender
$report = $result | %{ New-Object psobject -Property @{Sender=$.Name;Recipients=($ .Group | Measure-Object RecipientCount -Sum).Sum}} | Where-Object {$.Recipients -gt 100} | Sort-Object -Descending Recipients | Format-Table -AutoSize Sender,Recipients | Out-String
Send-MailMessage -From [email protected] -Subject "Exchange senders report: $(Get-Date -UFormat '%a, %D')" -To [email protected] -Body $report -SMTPserver smtp.contoso.com

线:如何设置每日报告,报告 24 小时内向组织外发送超过规定数量电子邮件的用户

答案2

请使用具体邮箱地址修改收件人邮箱地址”[电子邮件保护]“在以下脚本中:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
$output = Get-TransportServer | Get-MessageTrackingLog -Start (get-date).AddDays(-1) -ResultSize Unlimited | where{$ .EventId -eq "SEND" -or $.EventId -eq "SENDEXTERNAL" -and $ .Recipients -eq "[email protected]"}
$result = $output | Group-Object -Property Sender
$report = $result | %{ New-Object psobject -Property @{Sender=$.Name;Recipients=($ .Group | Measure-Object RecipientCount -Sum).Sum}} | Where-Object {$.Recipients -gt 100} | Sort-Object -Descending Recipients | Format-Table -AutoSize Sender,Recipients | Out-String
Send-MailMessage -From [email protected] -Subject "Exchange senders report: $(Get-Date -UFormat '%a, %D')" -To [email protected] -Body $report -SMTPserver smtp.contoso.com

相关内容