Skip to content

Commit 4cc42c5

Browse files
Mailbox Auditing changes
1 parent 8d7ea64 commit 4cc42c5

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardEnableMailboxAuditing.ps1

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ function Invoke-CIPPStandardEnableMailboxAuditing {
4949

5050
try {
5151
$AuditState = (New-ExoRequest -tenantid $Tenant -cmdlet 'Get-OrganizationConfig').AuditDisabled
52-
}
53-
catch {
52+
} catch {
5453
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
5554
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message "Could not get the EnableMailboxAuditing state for $Tenant. Error: $ErrorMessage" -Sev Error
5655
return
@@ -71,25 +70,30 @@ function Invoke-CIPPStandardEnableMailboxAuditing {
7170
$LogMessage = 'Tenant level mailbox audit already enabled. '
7271
}
7372

74-
# Check for mailbox audit on all mailboxes. Enable for all that it's not enabled for
75-
$Mailboxes = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-Mailbox' -cmdParams @{filter = "auditenabled -eq 'False'" } -useSystemMailbox $true -Select 'AuditEnabled,UserPrincipalName'
76-
$Request = $mailboxes | ForEach-Object {
77-
@{
78-
CmdletInput = @{
79-
CmdletName = 'Set-Mailbox'
80-
Parameters = @{Identity = $_.UserPrincipalName; AuditEnabled = $true }
81-
}
82-
}
83-
}
73+
# Commented out because MS recommends NOT doing this anymore. From docs: https://learn.microsoft.com/en-us/purview/audit-mailboxes#verify-mailbox-auditing-on-by-default-is-turned-on
74+
# When you turn on mailbox auditing on by default for the organization, the AuditEnabled property for affected mailboxes doesn't change from False to True. In other words, mailbox auditing on by default ignores the AuditEnabled property on mailboxes.
75+
# Auditing is automatically turned on when you create a new mailbox. You don't need to manually enable mailbox auditing for new users.
76+
# You don't need to manage the mailbox actions that are audited. A predefined set of mailbox actions are audited by default for each sign-in type (Admin, Delegate, and Owner).
77+
# When Microsoft releases a new mailbox action, the action might be added automatically to the list of mailbox actions that are audited by default (subject to the user having the appropriate license). This result means you don't need to add new actions on mailboxes as they're released.
78+
# You have a consistent mailbox auditing policy across your organization because you're auditing the same actions for all mailboxes.
79+
#$Mailboxes = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-Mailbox' -cmdParams @{filter = "auditenabled -eq 'False'" } -useSystemMailbox $true -Select 'AuditEnabled,UserPrincipalName'
80+
#$Request = $mailboxes | ForEach-Object {
81+
# @{
82+
# CmdletInput = @{
83+
# CmdletName = 'Set-Mailbox'
84+
# Parameters = @{Identity = $_.UserPrincipalName; AuditEnabled = $true }
85+
# }
86+
#}
87+
#}
8488

85-
$BatchResults = New-ExoBulkRequest -tenantid $tenant -cmdletArray @($Request)
86-
$BatchResults | ForEach-Object {
87-
if ($_.error) {
88-
$ErrorMessage = Get-NormalizedError -Message $_.error
89-
Write-Host "Failed to enable user level mailbox audit for $($_.target). Error: $ErrorMessage"
90-
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Failed to enable user level mailbox audit for $($_.target). Error: $ErrorMessage" -sev Error
91-
}
92-
}
89+
#$BatchResults = New-ExoBulkRequest -tenantid $tenant -cmdletArray @($Request)
90+
#$BatchResults | ForEach-Object {
91+
# if ($_.error) {
92+
# $ErrorMessage = Get-NormalizedError -Message $_.error
93+
# Write-Host "Failed to enable user level mailbox audit for $($_.target). Error: $ErrorMessage"
94+
# Write-LogMessage -API 'Standards' -tenant $Tenant -message "Failed to enable user level mailbox audit for $($_.target). Error: $ErrorMessage" -sev Error
95+
# }
96+
#}
9397

9498
# Disable audit bypass for all mailboxes that have it enabled
9599

0 commit comments

Comments
 (0)