Exchange 2010 Create and Apply Retention Policy

Today in this blog post, we will create Retention policy for Voice Mails in Exchange environment. As per our organization standards we don’t want to retain the Voice Emails beyond  30 days, therefore we will create a policy & will apply it to Unified Messaging mailboxes.

Note: please don’t use GUI on any step for creating these policies as we have seen issues when policy is  created via GUI (when applying those desired result was not achieved)

This is a 3 step process:

  1.  Create a new Retention Policy Tag: The Retention Policy for voicemail can only be setup using shell and this option is not available in EMC.

Shell Command:

New-RetentionPolicyTag -Name “Delete Voicemail after 30 days” -Type All -Comment “Voicemail older than 30 days will be deleted” -MessageClass Voicemail -RetentionEnabled $true -AgeLimitForRetention 60 -RetentionAction DeleteAndAllowRecovery

2. Create a new Retention Policy:

Shell Command:

New-RetentionPolicy “VoicemailRetentionPolicy” –RetentionPolicyTagLinks “Delete Voicemail after 30 days”

You can verify from Exchange management Console if these are created:(under organization section)

Capture

Now policy has been created but you want to apply it to only Unified Messaging users so here is the script that will assist you.

https://gallery.technet.microsoft.com/scriptcenter/Exchange-2010-Apply-f3edfd2e

This Script can be used to apply the retention policy on exchange 2010 UM mailboxes & also assists in applying to any new ones.

You can modify it according to your needs, We used it for Unified Messaging retention policy.

Change the Policy Name inside .ps1 as per your environment.

$pol = “VoicemailRetentionPolicy”

run the batch file or schedule the script via task scheduler

Script will apply the policy to any new UM mailboxes that are without retention, It also will show you on screen output as well as logs in csv inside the logs foler.

 

############################################################################# 
#       Author: Alex Rodrick 
#    Reviewer: Vikas Sukhija 
#       Date: 4/14/2016 
#       Description: Apply Voice email retetion policy 
############################################################################# 
 
# Add Exchange Shell... 
 
If ((Get-PSSnapin | where {$_.Name -match "Microsoft.Exchange.Management.PowerShell.E2010"}) -eq $null) 
{ Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010} 
 
 
#format Date 
 
$date = get-date -format d 
$date = $date.ToString().Replace(“/”, “-”) 
 
$output = ".\logs\" + "UMretentiongApplied_" + $date + "_.csv" 
 
$pol = "VoicemailRetentionPolicy" 
 
$ummbx = Get-UMMailbox -Resultsize:Unlimited | Get-Mailbox  | Where-Object{$_.RetentionPolicy -ne $pol}  | Select Name,Alias 
 
if($ummbx -ne $null){ 
foreach($i in $ummbx) 
  { 
   Write-host "Processing ..."$i.Name"..." -foregroundcolor green 
   Set-Mailbox $i.Alias -RetentionPolicy $pol 
  } 
 
$ummbx | export-csv $output -notypeinformation 
} 
 
else { 
Write-host " Nothing to Process" - foregroundcolor magenta 
 
} 
 
 
 
  
#############################################################################

Regards

Sukhija Vikas

http://msexchange.me

 

Advertisements

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