当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 从 Exchange 用户邮箱中搜索并删除电子邮件

作者:精品下载站 日期:2024-12-14 18:08:03 浏览:13 分类:玩电脑

从 Exchange 用户邮箱中搜索并删除电子邮件


财务部门的用户向错误的用户发送了一封电子邮件,并询问是否可以从 Exchange Server 中删除该电子邮件。用户将电子邮件发送给组织的内部用户。出现恐慌是因为用户不应该收到该电子邮件。系统将询问您是否可以从用户收件箱中删除该消息。本文将教您如何使用 PowerShell 从 Exchange 用户邮箱中搜索和删除电子邮件。

信息

在本文中,用户 Amanda Morgan ([email protected]) 于 2020 年 9 月 10 日(2020 年 10 月 9 日)向用户 Christopher Payne ([email protected]) 发送了一封电子邮件。我们不知道这个话题。但我们有她发送电子邮件的估计时间。那是 00:00 左右。我们将如何完成使命?

您想从所有邮箱中搜索并删除该电子邮件吗?阅读文章搜索并删除 Exchange 用户邮箱中的邮件。

获取电子邮件主题

首先,我们需要搜索从 Amanda 发送给 Christopher 的所有电子邮件。如果我们找到了已发送的电子邮件,我们就可以获得带有主题的特定电子邮件。在开始之前,请确保您的 C:\ 驱动器上有一个 temp 文件夹。如果没有,请创建一个名为 temp 的文件夹。

过滤特定日期

以管理员身份运行 Exchange 命令行管理程序。使用 Get-MessageTrackingLog cmdlet 获取当天从 Amanda 到 Christopher 的所有消息的日志。

[PS] C:\>Get-MessageTrackingLog -Start "10/09/2020 00:00:00" -End "10/09/2020 23:59:59" -Sender "[email protected]" -Recipients "[email protected]" -ResultSize Unlimited | Format-Table -AutoSize

如果用户发送了很多电子邮件,那么找到该特定电子邮件并不容易。幸运的是,PowerShell 功能强大,我们可以根据自己的喜好过滤结果。让我们看看如何做到这一点。

过滤特定日期和时间

搜索特定时间,在我们的例子中,从 00:00:00 - 00:30:00。

[PS] C:\>Get-MessageTrackingLog -Start "10/09/2020 00:00:00" -End "10/09/2020 00:30:00" -Sender "[email protected]" -Recipients "[email protected]" -ResultSize Unlimited | Format-Table -AutoSize

Timestamp             EventId        Source      Sender                  Recipients                    MessageSubject
---------             -------        ------      ------                  ----------                    --------------
10/9/2020 12:02:09 AM HAREDIRECTFAIL SMTP        [email protected] {[email protected]} Earnings per month
10/9/2020 12:02:09 AM RECEIVE        SMTP        [email protected] {[email protected]} Earnings per month
10/9/2020 12:02:09 AM AGENTINFO      AGENT       [email protected] {[email protected]} Earnings per month
10/9/2020 12:02:09 AM SEND           SMTP        [email protected] {[email protected]} Earnings per month
10/9/2020 12:02:09 AM RECEIVE        STOREDRIVER [email protected] {[email protected]} Earnings per month
10/9/2020 12:02:09 AM SUBMIT         STOREDRIVER [email protected] {[email protected]} Earnings per month
10/9/2020 12:02:09 AM DELIVER        STOREDRIVER [email protected] {[email protected]} Earnings per month

使用 Out-GridView cmdlet

使用 Out-GridView cmdlet 将输出发送到单独窗口中的交互式表。

[PS] C:\>Get-MessageTrackingLog -Start "10/09/2020 00:00:00" -End "10/09/2020 00:30:00" -Sender "[email protected]" -Recipients "[email protected]" -ResultSize Unlimited | Out-GridView

输出将显示如下。

[玩转系统] 从 Exchange 用户邮箱中搜索并删除电子邮件

导出至 CSV 文件

我们希望将信息导出到 CSV 文件。

[PS] C:\>Get-MessageTrackingLog -Start "10/09/2020 00:00:00" -End "10/09/2020 00:30:00" -Sender "[email protected]" -Recipients "[email protected]" -ResultSize Unlimited | Select Timestamp,EventId,Source,Sender,@{Name='Recipients';Expression={[string]::join(";", ($_.recipients))}},MessageSubject | Export-Csv "c:\temp\get_list.csv" -NoTypeInformation

使用您喜欢的应用程序打开 CSV 文件。在我们的示例中,是 Microsoft Excel。

[玩转系统] 从 Exchange 用户邮箱中搜索并删除电子邮件

现在我们有了主题,我们可以从 Christopher 的邮箱中删除 Amanda 的电子邮件。

从 Exchange 中删除电子邮件

当我们以 Christopher 用户身份登录 Outlook 时,我们可以看到来自 Amanda 的电子邮件。

[玩转系统] 从 Exchange 用户邮箱中搜索并删除电子邮件

运行以下命令从 Christopher 的邮箱中删除电子邮件。按Y确认并按Enter

[PS] C:\>Search-Mailbox -Identity "[email protected]" -SearchQuery 'Subject:"Earnings per month"' -DeleteContent
WARNING: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a search query is specified. To return more than 10000 results, use the New-MailboxSearch cmdlet or the In-Place eDiscovery & Hold console
in the Exchange Administration Center.

Confirm
Deleting content from mailboxes [email protected]
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): Y


RunspaceId       : 615c7ca9-d995-4908-800f-be75565ece89
Identity         : exoip.local/Company/Users/Finance/Christopher Payne
TargetMailbox    :
Success          : True
TargetFolder     :
ResultItemsCount : 1
ResultItemsSize  : 7.732 KB (7,918 bytes)

如果您不想确认,请运行相同的命令从 Exchange 用户邮箱中删除电子邮件,但这次使用 -Force 开关。它将运行命令并删除电子邮件,而不要求确认。

[PS] C:\>Search-Mailbox -Identity "[email protected]" -SearchQuery 'Subject:"Earnings per month"' -DeleteContent -Force
WARNING: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a search query is specified. To return more than 10000 results, use the New-MailboxSearch cmdlet or the In-Place eDiscovery & Hold console
in the Exchange Administration Center.


RunspaceId       : 615c7ca9-d995-4908-800f-be75565ece89
Identity         : exoip.local/Company/Users/Finance/Christopher Payne
TargetMailbox    :
Success          : True
TargetFolder     :
ResultItemsCount : 1
ResultItemsSize  : 7.732 KB (7,918 bytes)

邮件已成功从邮箱中删除。

验证结果

看看克里斯托弗的邮箱。电子邮件已被删除。

[玩转系统] 从 Exchange 用户邮箱中搜索并删除电子邮件

值得高兴的是,该电子邮件将被完全删除。它不会被移动到用户的已删除项目中。此外,用户无法从已删除的项目中恢复它。

[玩转系统] 从 Exchange 用户邮箱中搜索并删除电子邮件

电子邮件从 Exchange Server 中的用户邮箱中删除。它能为您提供帮助吗?

了解更多:测试 Exchange Server 中的内部邮件流 »

结论

在本文中,您了解了如何使用 PowerShell 从 Exchange 用户邮箱中删除电子邮件。我们首先使用 PowerShell 优化搜索结果以查找发送的电子邮件主题。之后,我们运行了 Search-Mailbox cmdlet,包括 -DeleteContent 开关以从用户邮箱中删除电子邮件。

您喜欢这篇文章吗?您可能还喜欢在 Exchange Server 中创建用户邮箱。不要忘记关注我们并分享这篇文章。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯