Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement