Skip to content

Instantly share code, notes, and snippets.

@chrisbrownie
Created November 2, 2016 11:17
Show Gist options
  • Save chrisbrownie/16affe1e52966a998d6f985a349c929e to your computer and use it in GitHub Desktop.
Save chrisbrownie/16affe1e52966a998d6f985a349c929e to your computer and use it in GitHub Desktop.
Enable Litigation Hold for all Mailboxes in Office 365 https://flamingkeys.com/enable-litigation-hold-for-all-mailboxes-in-office-365/
# Connect to Exchange Online
$exo = New-PSSession -ConfigurationName Microsoft.Exchange `
-ConnectionUri https://ps.outlook.com/powershell-liveid `
-Authentication Basic `
-AllowRedirection `
-Credential $(Get-credential)
Import-PSSession $exo
# Get all mailboxes that do not have litigation hold enabled
$mailboxes = Get-Mailbox -ResultSize Unlimited -Filter {RecipientTypeDetails -eq "UserMailbox"} |
Where {$_.LitigationHoldEnabled -ne $true}
# Enable litigation hold
$mailboxes | Set-Mailbox -LitigationHoldEnabled $true
Remove-PSSession $exo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment