Enable Legal Hold by using PowerShell


Statement:
You have purchased some Office 365 E3 plans and have assigned the Office 365 E3 licenses to the users.
You would like to activate Legal Hold for these users in bulk, using PowerShell.
Script to Activate:
# 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 -andRecipientTypeDetails -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);Source: Goodworkaround.com
Posted in Office365 | Comments Off on Enable Legal Hold by using PowerShell