Applying database and mailbox retention settings with Powershell One Liners

Applying database and mailbox retention settings with Powershell One Liners


Set to True RetainDeletedItemsUntilBackup for all Databases:

Get-MailboxDatabase | Set-MailboxDatabase -RetainDeletedItemsUntilBackup:$True


Set DeletedItemRetention to 14days for all Mailbox Databases:

Get-MailboxDatabase | Set-MailboxDatabase -DeletedItemRetention 14


Set UseDatabaseRetentionDefaults to True for all mailboxes:

Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')} | Set-Mailbox -UseDatabaseRetentionDefaults:$true