Retention Policy Powershell Commands

Retention Policy Powershell Commands

I’ve recently been working on applying retention policies to mailboxes and we’ve been doing a granular roll-out to the users.  I’ve been using some Powershell commands to track who has the policy applied and who hasn’t.

The following command will list all users who have a retention policy applied to their mailbox:

Get-Mailbox -filter ‘RetentionPolicy -like “*”‘ | Select-Object Name, RetentionPolicy

You can export that to a CSV if need be by using:

 Get-Mailbox -filter ‘RetentionPolicy -like “*”‘ | Select-Object Name, RetentionPolicy | Export-CSV C:directoryfile.csv

To identify which users don’t have a retention policy applied to their mailbox the following command will assist:

Get-Mailbox -filter ‘RetentionPolicy -eq $null’ | Select-Object Name, RetentionPolicy

Again to export that to CSV you would use:

Get-Mailbox -filter ‘RetentionPolicy -eq $null’ | Select-Object Name, RetentionPolicy | Export-CSV C:Directoryfile.csv