Skip to content

Instantly share code, notes, and snippets.

@glides
Last active May 4, 2021 19:01
Show Gist options
  • Save glides/71bf3e5bbee3b6b3cad00fd1cf019c5c to your computer and use it in GitHub Desktop.
Save glides/71bf3e5bbee3b6b3cad00fd1cf019c5c to your computer and use it in GitHub Desktop.
Enabled logging for all o365 users.
## There are oneliners that try to enable logging for all users but in a large environment you will run into a data cap for the session - that is why this is split up using a foreach loop
$mailboxes = Get-Mailbox -ResultSize Unlimited -Filter {RecipientTypeDetails -eq "UserMailbox" -or RecipientTypeDetails -eq "SharedMailbox" -or RecipientTypeDetails -eq "RoomMailbox" -or RecipientTypeDetails -eq "DiscoveryMailbox"}
foreach($m in $mailboxes) {
Set-Mailbox $m.Identity.ToString() -AuditEnabled $true -AuditLogAgeLimit 180 -AuditOwner Create,HardDelete,MailboxLogin,Move,MoveToDeletedItems,SoftDelete,Update,UpdateFolderPermissions -AuditDelegate Create,HardDelete,Move,MoveToDeletedItems,SendAs,SendOnBehalf,SoftDelete,Update,UpdateFolderPermissions -AuditAdmin Copy,Create ,HardDelete ,Move,MoveToDeletedItems,SendAs,SendOnBehalf,SoftDelete,Update,UpdateFolderPermissions
Start-Sleep -Milliseconds 75
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment