PowerShell – Retention (Tags & Policy)

Create a new Retention Tag

New-RetentionPolicyTag -Name 1DAY -Type ‘Personal’ -AgeLimitForRetention 1 -RetentionAction ‘DeleteAndAllowRecovery’ -RetentionEnabled $true

Get a List of all Retention Tags

Get-RetentionPolicyTag

image

Create a new Retention Policy

New-RetentionPolicy “Company Policy” -RetentionPolicyTagLinks “Company Policy-Deleted Items”,”Company Policy-Sent Items”

Apply a new Retention Policy to ALL users

$UserMailboxes = Get-mailbox -Filter {(RecipientTypeDetails -eq ‘UserMailbox’)}

$UserMailboxes | Set-Mailbox –RetentionPolicy “Company Retention Policy”

Run Managed Folder Assistant to apply new Retention Policy

$UserMailboxes = Get-mailbox -Filter {(RecipientTypeDetails -eq ‘UserMailbox’)}

$UserMailboxes | ForEach {Start-ManagedFolderAssistant $_.Identity}

Verify Retention Policy is Applied to ALL users

Get-Mailbox -ResultSize unlimited | where {$_.name -Notlike ‘*DiscoverySearchMailbox*’} | select Alias,RetentionPolicy