User Database Retention Default

In Exchange 2007, to enable the recovery dumpster, the user database retention default has to be checked. If its unchecked, you are allowed to specify a time (other than the default of 14 days.) but when you do uncheck it, the recovery dumpster is no longer available.

So the below code will check to see who has the retention default unchecked.

$date = ( get-date ).ToString(‘MM-dd-yyyy’)
$AllServers = @()
#Create a hash Table to hold the freespace information
$hashUDRD = @{}
#Clear the hash Table just in case
$stream = [System.IO.StreamWriter] ‘C:\Retention.txt’
$mailboxRET = Get-Mailbox -ResultSize 3000 | sort-object UseDatabaseRetentionDefaults| Select displayName,UseDatabaseRetentionDefaults
foreach ($objectItem in $mailboxRET)
$IsItSet = $objectItem.UseDatabaseRetentionDefaults
if (-not $IsItSet) {
#if ($IsItSet) {
$s = $objectItem.displayName+”,”+$objectItem.UseDatabaseRetentionDefaults
If ((Get-Content “C:\Retention.txt”) -eq $Null)
Remove-Item ‘C:\Retention.txt’
$info = get-content ‘C:\Retention.txt’
foreach ($i in $info) {
$item = $i.split(“,”)
$ReturnedObj = New-Object PSObject
$LName = $item[0]
$TFName = $item[1]
$FName = $TFName.TrimStart(” “)
$username = $Lname+”, “+$FName
$ReturnedObj | Add-Member -MemberType NoteProperty -Name “User Name” -Value $username
$ReturnedObj | Add-Member -MemberType NoteProperty -Name “Database Retention Defaults” -Value $item[2]
$AllServers += $ReturnedObj
Remove-Item ‘C:\Retention.txt’
#$AllServers |Export-Csv E:\PSOutput\RetentionDefaultReport.csv -NoTypeInformation
$body = “Database Retention Defaults report for $date

$bodydetail = $AllServers |sort-object “User Name” |convertto-html
$body = $body + $bodydetail
Send-MailMessage -To “” -Body $body -Subject “Retention Defaults Report” -SmtpServer “” -BodyAsHtml:$true -From “”

This entry was posted in Powershell. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *