# Generate a list of mailboxes whose litigation hold duration is less than a week away

• 1
•
•
•
•
•
1
Share

While many people use Office 365 retention policies as part of their data governance strategy, there are many customers who either do not enforce retention or do so only for items under some sort of litigation hold.

In the olden days, when storage was at a premium, it was much more common to handle things this way.  Some customers still do, and that’s A-OK. If it ain’t broke, you either aren’t trying hard enough or maybe the solution is just fine.

To that end, you may find yourself (or a customer) putting a mailbox on hold for a specific duration and wanting to be notified when that duration has been reached.

Here’s a script to do just that:

$SmtpServer = "smtpserver.domain.com";$To = @("recipient1@domain.com", "recipient2@domain.com");
$From = "noreply@domain.com";$NotificationWarningWindow = 7;
[System.Collections.ArrayList]$obj = @();$Today = Get-Date;
[array]$mailboxes = Get-Mailbox -ResultSize Unlimited -Filter { LitigationHoldEnabled -eq$true } | Select DisplayName, PrimarySmtpAddress, Litigation*
foreach ($mailbox in$mailboxes)
{
$ExpirationDate =$mailbox.LitigationHoldDate + $mailbox.LitigationHoldDuration; If (($ExpirationDate - $Today).Days -lt$NotificationWarningWindow)
{
Write-Host "Warning: Litigation Hold for $($mailbox.PrimarySmtpAddress.ToString()) expires in less than $($NotificationWarningWindow) days"
$hashtemp = @{ DisplayName =$mailbox.DisplayName;
PrimarySmtpAddress = $mailbox.PrimarySmtpAddress; ExpirationDate =$ExpirationDate
};
$objtemp = New-Object PSObject -Property$hashtemp;
$obj +=$objtemp;
Remove-Variable hashtemp,objtemp
}
}

[String]$Body =$obj.GetEnumerator() | %{ "n$($_.ExpirationDate)," + "$($_.PrimarySmtpAddress)," + "$($_.DisplayName)" }
Send-MailMessage -SmtpServer $SmtpServer -To$To -From $From -Subject "Litigation Hold expiring in the next 7 days" -Body$Body`

Hold the mayo, hold the mailbox, but don’t hold me up.