Home > Exchange, Exchange 2010, Microsoft, PowerShell, Scripts > Script to automatically assign Archive users to a retention policy

Script to automatically assign Archive users to a retention policy


 

Quick script that will assign all archive users (i.e. people with an Exchange archive) to a retention policy (that you have created to archive email, obviously). Then runs a “start-managedfolderassistant” to apply.

 

Obviously “Move after 90 days” is the retention policy name. Tested with 2010 SP1.

 

Ciao

 

$mailboxes = get-mailbox | where-Object ({$_.ArchiveDatabase -ne $null})

$mailboxes | foreach-object {

if ($_.RetentionPolicy -eq "Move after 90 days") {

write-output ("User " + $_.Name + " already assigned, skipping")

}

else {

set-mailbox $_ -RetentionPolicy "Move after 90 days"

write-output ("User " + $_.Name + " set correctly")

}

}

write-output "Users assigned, starting Managed Folder Assistant"

get-mailbox | Where-Object ({$_.ArchiveDatabase -ne $null}) | start-managedfolderassistant

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: