The following PowerShell script will enable litigation hold for all user mailboxes in your environment. The script will work for Exchange 2010 and 2013, both On-Premise or Online.
# First you need to be connected to the Exchange PowerShell.
$pagesize = 100; # The number of mailboxes per loop
$inc = 0; # Start increment value
# Continue until all mailboxes are litigation hold enabled
do {
Write-Output "Getting mailboxes"
# Get UserMailboxes that does not have litigation hold enabled
$mailboxes = Get-Mailbox -Filter {LitigationHoldEnabled -eq $false -and RecipientTypeDetails -eq "UserMailbox"} -ResultSize $pagesize -WarningAction SilentlyContinue
if($mailboxes) { Write-Output ("Current mailbox count: {0}" -f ($inc += $mailboxes.Count))}
# Enable litigation hold
$mailboxes | Set-Mailbox -LitigationHoldEnabled $true -WarningAction SilentlyContinue
} while($mailboxes);
Write-Output "Done"
It is possible to add additional filtering by editing the filter for the Get-Mailbox cmdlet.