Advertisement
mariussm

PowerShell script to enable litigation hold for all user mai

Feb 5th, 2014
4,271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # First you need to be connected to the Exchange PowerShell.
  2.  
  3. $pagesize = 100; # The number of mailboxes per loop
  4. $inc = 0; # Start increment value
  5.  
  6. # Continue until all mailboxes are litigation hold enabled
  7. do {
  8.     Write-Output "Getting mailboxes"
  9.     # Get UserMailboxes that does not have litigation hold enabled
  10.     $mailboxes = Get-Mailbox -Filter {LitigationHoldEnabled -eq $false -and RecipientTypeDetails -eq "UserMailbox"} -ResultSize $pagesize -WarningAction SilentlyContinue
  11.     if($mailboxes) { Write-Output ("Current mailbox count: {0}" -f ($inc += $mailboxes.Count))}
  12.     # Enable litigation hold
  13.     $mailboxes | Set-Mailbox -LitigationHoldEnabled $true -WarningAction SilentlyContinue
  14. } while($mailboxes);
  15.  
  16. Write-Output "Done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement