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

[玩转系统] 使用 PowerShell 管理邮箱审核 |办公室365

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

使用 PowerShell 管理邮箱审核 |办公室365


在本文中,我们将回顾使用 PowerShell 命令的“Exchange Online 审核选项”的各个方面。

连接到 Exchange Online 保护

为了能够运行本文中指定的 PowerShell 命令,您需要连接到 Exchange Online PowerShell。

以管理员身份启动 Windows PowerShell 并运行 cmdlet Connect-ExchangeOnline

Connect-ExchangeOnline

有关 Exchange 审核选项的基本信息

Exchange Online Audit 功能是一个非常强大的工具,使我们能够获取有关特定 Exchange 邮箱中执行的每个“操作”的详细信息。

审核信息保存在专用日志文件中,该日志文件存储在邮箱中(该日志文件对邮箱所有者隐藏)。

Exchange 审核邮箱选项默认情况下未“激活”
Exchange Online 审核选项最常见的用途是在特定用户邮箱发生“异常情况”的情况下。例如,在用户(邮箱所有者)不知情的情况下删除的邮件或日历会议、重新定位到其他文件夹的邮件项目等。

在这种类型的场景中,为了能够了解“幕后”发生的情况,我们需要监视与特定 Exchange 邮箱相关的每个“事件”。使用 Exchange 审核日志中存储的信息将使我们能够了解执行上述操作时执行的确切操作以及由谁执行。

Exchange Online 支持四种类型的审核选项:

1.邮箱所有者审核(AuditOwner)

这种类型的审核将“记录”邮箱所有者执行的不同操作,例如邮件项目删除和不同类型的邮件项目删除 - 软删除硬删除 、创建邮件项目、移动邮件项目、更新现有邮件项目等等。

2.非所有者(委托)审计(AuditDelegate)

这种类型的审核与“其他用户”有权访问特定用户邮箱的情况相关。 “其他”用户定义为委托

审计信息将包括与 AuditOwner 相同的操作,此外还包括其他操作,例如委托执行操作的事件 - SendAs

3.管理审核(AuditAdmin)

此类审核将记录 Exchange Online 管理员执行的“操作”。此类审核将与 Exchange Online 管理员直接对特定用户邮箱执行的操作相关。例如,Exchange 管理员使用 PowerShell 命令从用户邮箱中搜索和删除电子邮件项目的场景。

4. Office 365 管理审核(搜索-AdminAuditLog)

这是默认为 Office 365 客户启用的特殊审核日志。此审核的目的是记录 Exchange Online 管理员执行的每项“管理操作”。例如,为特定用户邮箱分配对“其他用户”的完全访问权限、分配代理发送权限、添加或删除电子邮件地址等操作。

使用 Exchange Online 审核选项

Exchange Online Audit 的使用可能有点令人困惑。因此,了解激活和使用审计信息所应使用的确切操作“流程”非常重要。

  • 阶段 1#3 - 在此阶段,我们为特定邮箱“打开”Exchange“审核标志”。
  • 阶段 2#3 - 在此阶段,我们定义要审核的特定“操作”,例如删除邮件等。如果您需要有关我们可以为每种不同审核类型定义的特定“操作”的更多信息,您可以使用我在当前文章底部添加的表格。
  • 阶段 3#3 - 在此阶段,我们“读取”Exchange 审核日志。从技术上讲,我们使用PowerShell命令在PowerShell控制台上显示审核日志内容,但从我的经验来看,读取这些信息并不那么容易。

建议将审核日志信息导出到 CSV 或 HTML 等格式的文件中,这将使我们能够更好地理解 Exchange 审核日志中的信息,通过过滤特定“操作”等对信息进行排序。

在本文后面,我将提供一些示例 - 如何使用 CSS 样式将审核日志信息导出到 CSV 文件和 HTML 文件格式,这将以更漂亮的方式显示信息。

对 Exchange 邮箱启用审核 + 激活特定审核选项

对 Exchange 邮箱启用审核

PowerShell命令语法:

Set-Mailbox <Identity> -AuditEnabled $True

PowerShell 命令示例:

Set-Mailbox "Bob" -AuditEnabled $True

对所有邮箱启用审核(批量模式)

PowerShell 命令示例:

Get-Mailbox -ResultSize Unlimited | ForEach {Set-Mailbox $_.UserPrincipalName -AuditEnabled $True}

对 Exchange 邮箱启用所有者审核

PowerShell命令语法:

Set-Mailbox <Identity> -AuditOwner <required parameters>

PowerShell 命令示例:

Set-Mailbox "Bob" -AuditOwner Create,HardDelete,MailboxLogin,Move,MoveToDeletedItems,SoftDelete,Update

对 Exchange 邮箱启用非所有者(委托)审核

PowerShell命令语法:

Set-Mailbox <Identity> -AuditDelegate <required parameters>

PowerShell 命令示例:

Set-Mailbox "Bob" -AuditDelegate Create,FolderBind,HardDelete,Move,MoveToDeletedItems,SoftDelete,Update

对 Exchange 邮箱启用管理员审核

PowerShell命令语法:

Set-Mailbox <Identity> -AuditAdmin <required parameters>

PowerShell 命令示例:

Set-Mailbox "Bob" -AuditAdmin Copy,Create,FolderBind,HardDelete,MessageBind,Move,MoveToDeletedItems,SendAs,SendOnBehalf,SoftDelete,Update

查看 Exchange 邮箱审核设置

查看Exchange邮箱的审核设置

PowerShell命令语法:

Get-Mailbox <Identity> | FL Audit*

PowerShell 命令示例:

Get-Mailbox "Bob" | FL Audit*

PowerShell 控制台输出示例:

PS C:\script> Get-Mailbox "Bob" | FL Audit*

AuditEnabled : True
AuditLogAgeLimit : 90.00:00:00
AuditAdmin : {Update, Copy, Move, MoveToDeletedItems...}
AuditDelegate : {Update, Move, MoveToDeletedItems, SoftDelete...}
AuditOwner : {Update, Move, MoveToDeletedItems, SoftDelete...}

查看审计参数 - AuditOwner(展开)

PowerShell 命令示例:

Get-Mailbox "Bob" | Select-Object -ExpandProperty AuditOwner

PowerShell 控制台输出示例:

Get-Mailbox "Bob" | Select-Object -ExpandProperty AuditOwner

Update
Move
MoveToDeletedItems
SoftDelete
HardDelete
Create
MailboxLogin

查看 - AuditAdmin 的审核参数(展开)

PowerShell 命令示例:

Get-Mailbox "Bob" | Select-Object -ExpandProperty AuditAdmin

PowerShell 控制台输出示例:

Get-Mailbox "Bob" | Select-Object -ExpandProperty AuditAdmin

Update
Copy
Move
MoveToDeletedItems
SoftDelete
HardDelete
FolderBind
SendAs
SendOnBehalf
MessageBind
Create

查看审核日志信息

查看审核日志信息 |所有审计类型

PowerShell命令语法:

Search-MailboxAuditLog <Identity> -LogonTypes <Audit type>, <Audit type> -ShowDetails

PowerShell 命令示例:

Search-MailboxAuditLog "Bob" -LogonTypes Admin, Owner,Delegate -ShowDetails

PowerShell 控制台输出示例:

Search-MailboxAuditLog "Bob" -LogonTypes Admin, Owner,Delegate -ShowDetails

RunspaceId : 9c1c9ae6-1c61-4a9e-8d2c-5f67c0142d9f
Operation : FolderBind
OperationResult : Succeeded
LogonType : Delegate
ExternalAccess : False
DestFolderId :
DestFolderPathName :
FolderId : LgAAAABEWzQUHcpBSYfBaz2R78jhAQDK7xgSkvxcTrNBen7hewMRAAAAAAFRAAAB
FolderPathName : \Sync Issues\Conflicts
ClientInfoString : Client=MSExchangeRPC
ClientIPAddress : 93.172.209.9
ClientMachineName :
ClientProcessName : OUTLOOK.EXE
ClientVersion : 16.0.7369.6540
InternalLogonType : Owner
MailboxOwnerUPN : [email protected]
MailboxOwnerSid : S-1-5-21-2103643036-1067027473-1901050440-16161243
DestMailboxOwnerUPN :
DestMailboxOwnerSid :
DestMailboxGuid :
CrossMailboxOperation :
LogonUserDisplayName : Angelina Jolie
LogonUserSid : S-1-5-21-2103643036-1067027473-1901050440-14666822
SourceItems : {}
SourceFolders : {}
SourceItemIdsList :
SourceItemSubjectsList :
SourceItemAttachmentsList :
SourceItemFolderPathNamesList :
SourceFolderPathNamesList :
ItemId :
ItemSubject :
ItemAttachments :
DirtyProperties :
OriginatingServer : DB5PR05MB1384 (15.01.0761.009)
MailboxGuid : 6cfec3d7-878b-4393-aa96-cbb6e8fd008c
MailboxResolvedOwnerName : Bob marley
LastAccessed : 12/06/2016 4:01:14 AM
Identity : AAMkAGNjYmNkN2Q3LTc2ZGQtNDMwOC05ZmVlLTI3OTY5Njg0ZTEzZgBGAAAAAABEWzQUHcpBSYfBaz2R78jhBwDK7xgSkvxcTrNBen7hewMRAAAJziBGAADK7xgSkvxcTrNBen7hewMRAAAJziRMAAA=
IsValid : True
ObjectState : NewRunspaceId : 9c1c9ae6-1c61-4a9e-8d2c-5f67c0142d9f
Operation : FolderBind
OperationResult : Succeeded
LogonType : Delegate
ExternalAccess : False
DestFolderId :
DestFolderPathName :
FolderId : LgAAAABEWzQUHcpBSYfBaz2R78jhAQDK7xgSkvxcTrNBen7hewMRAAAAAAFQAAAB
FolderPathName : \Sync Issues
ClientInfoString : Client=MSExchangeRPC
ClientIPAddress : 93.172.209.9
ClientMachineName :
ClientProcessName : OUTLOOK.EXE
ClientVersion : 16.0.7369.6540
InternalLogonType : Owner
MailboxOwnerUPN : [email protected]
MailboxOwnerSid : S-1-5-21-2103643036-1067027473-1901050440-16161243

显示启用审核的邮箱

PowerShell 命令示例:

Get-Mailbox -ResultSize Unlimited | Where {$_.AuditEnabled -eq "$True"} | FL Alias ,Audit*

PowerShell 控制台输出示例:

PS C:\script> Get-Mailbox | Where {$_.AuditEnabled -eq "$True"} |FL Alias ,Audit*

Alias : Adele
AuditEnabled : True
AuditLogAgeLimit : 90.00:00:00
AuditAdmin : {Update, Move, MoveToDeletedItems, SoftDelete...}
AuditDelegate : {Update, SoftDelete, HardDelete, SendAs...}
AuditOwner : {}Alias : admin
AuditEnabled : True
AuditLogAgeLimit : 90.00:00:00
AuditAdmin : {Update, Move, MoveToDeletedItems, SoftDelete...}
AuditDelegate : {Update, SoftDelete, HardDelete, SendAs...}
AuditOwner : {}Alias : Alicia
AuditEnabled : True
AuditLogAgeLimit : 90.00:00:00
AuditAdmin : {Update, Move, MoveToDeletedItems, SoftDelete...}
AuditDelegate : {Update, SoftDelete, HardDelete, SendAs...}
AuditOwner : {}

将审核日志信息导出到 CSV 文件

将所有审核类型日志导出到 CSV 文件

PowerShell命令语法:

Search-MailboxAuditLog <Identity> -LogonTypes <Audit type>, <Audit type> -ShowDetails | Export-CSV <Path>" -NoTypeInformation -Encoding UTF8

PowerShell 命令示例:

Search-MailboxAuditLog "Bob" -LogonTypes Owner,Delegate,Admin -ShowDetails | Export-CSV c:\temp\"Audit Log.CSV" -NoTypeInformation -Encoding UTF8

导出有关特定事件的审核信息 |删除事件

PowerShell命令语法:

Search-MailboxAuditLog <Identity> -operations HardDelete,SoftDelete,MoveToDeletedItems -LogonTypes <Audit type>, <Audit type> -ShowDetails | Export-CSV <Path>" -NoTypeInformation -Encoding UTF8

PowerShell 命令示例:

Search-MailboxAuditLog "Bob" -operations HardDelete,SoftDelete,MoveToDeletedItems -LogonTypes Owner,Delegate,Admin -ShowDetails | Export-CSV c:\temp\"Audit Log.CSV" -NoTypeInformation -Encoding UTF8

将代表 + 所有者 + 管理员日志导出到文件按特定日期范围过滤结果 |过去 30 天

PowerShell 命令示例:

Search-MailboxAuditLog "Bob" -LogonTypes Admin, Owner,Delegate -ShowDetails -StartDate (Get-Date).AddDays(-30)| Export-CSV c:\temp\"Audit Log.CSV" -NoTypeInformation -Encoding UTF8

导出 Office 365 门户管理审核日志

PowerShell 命令示例:

Search-AdminAuditLog | Export-CSV c:\temp\"Search-AdminAuditLog.CSV" -NoTypeInformation -Encoding UTF8

导出特定 PowerShell cmdlet 的 Office 365 管理员审核日志

PowerShell 命令示例:

Search-AdminAuditLog -Cmdlets Enable-AddressListPaging| Export-CSV c:\temp\"Search-AdminAuditLog.CSV" -NoTypeInformation -Encoding UTF8

导出对特定邮箱执行的“管理操作”的 Office 365 门户管理员审核日志

PowerShell 命令示例:

Search-AdminAuditLog -ObjectIds "Bob" | Export-CSV c:\temp\"Search-AdminAuditLog.CSV" -NoTypeInformation -Encoding UTF8

禁用审核

禁用 Exchange 邮箱审核

PowerShell命令语法:

Set-Mailbox -Identity <Identity> -AuditEnabled $False

PowerShell 命令示例:

Set-Mailbox -Identity "Bob" -AuditEnabled $False

禁用所有邮箱的审核(批量模式)

PowerShell 命令示例:

Get-Mailbox -ResultSize Unlimited | ForEach {Set-Mailbox $_.UserPrincipalName -AuditEnabled $False}

其他 Exchange 审核选项

查看有关“审核文件夹”(审核日志存储)的信息

PowerShell 命令示例:

Get-MailboxFolderStatistics "Bob" | Where{$_.name eq "Audits"} | Format-Table Identity, ItemsInFolder, FolderSize -AutoSize

启用邮箱审核绕过关联

PowerShell 命令示例:

Set-MailboxAuditBypassAssociation -Identity "Bob" -AuditBypassEnabled $True

设置审核保留 - 天数

PowerShell命令语法:

Set-Mailbox <Identity> -AuditLogAgeLimit <Days>

PowerShell 命令示例:

Set-Mailbox "John" -AuditLogAgeLimit 30

使用 CSS 样式将审核日志信息导出到 HTML 文件

由邮箱审核日志记录记录的邮箱操作。

ActionDescriptionAdminDelegate***OwnerCopyA message was copied to another folder.YesNoNoCreateAn item is created in the Calendar, Contacts, Notes, or Tasks folder in the mailbox; for example, a new meeting request is created. Note that message or folder creation isn’t audited.Yes*Yes*YesFolderBindA mailbox folder was accessed. This action is also logged when the admin or delegate opens the mailbox.Yes*Yes*NoHardDeleteA message was purged from the Recoverable Items folder.Yes*Yes*YesMailboxLoginThe user signed in to their mailbox.NoNoYesMessageBindA message was viewed in the preview pane or opened.YesNoNoMoveA message was moved to another folder.Yes*YesYesMoveToDeletedItemsA message was deleted and moved to the Deleted Items folder.Yes*YesYesSendAsA message was sent using the SendAs permission. This means another user sent the message as though it came from the mailbox owner.Yes*Yes*NoSendOnBehalfA message was sent using the
SendOnBehalf permission. This means another user sent the message on behalf of the mailbox owner. The message indicates to the recipient who the message was sent on behalf of and who actually sent the message.Yes*YesNoSoftDeleteA message was permanently deleted or deleted from the Deleted Items folder. Soft-deleted items are moved to the Recoverable Items folder.Yes*Yes*YesUpdateA message or its properties was changed.Yes*Yes*Yes

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

取消回复欢迎 发表评论:

关灯