Monday, 16 March 2015

Enable LitigationHold in Bulk Script




Organizations often comes up with requirement from legal to enable Litigation hold in Bulk, In those cases below script can be helpful

Script 1 : To enable for all user in Bulk, You can run below command:

Get-Mailbox -ResultSize Unlimited -Filter {RecipientTypeDetails -eq "UserMailbox"} | Set-Mailbox -LitigationHoldEnabled $true

Script 2 : To Enable only to those set to False:

Get-Mailbox | Where {$_.LitigationHoldEnabled -match "False"} | ForEach-Object {$Identity = $_.SAMAccountName; Set-Mailbox -Identity $Identity -LitigationHoldEnabled $true}

Script 3 : To Enable Based on UPN:

Get-Mailbox | Where {$_.UserPrincipalName -like "*@domain.com"} | ForEach-Object {$Identity = $_.SAMAccountName; Set-Mailbox -Identity $Identity -LitigationHoldEnabled $true}

Script 4 : To Enable Based on UPN & Filter Litigation Set to False.

$UPN = Get-Mailbox | Where {$_.UserPrincipalName -like "*@domain.com"}

$UPN | Where {$_.LitigationHoldEnabled -match "False"} | ForEach-Object {$Identity = $_.SAMAccountName; Set-Mailbox -Identity $Identity -LitigationHoldEnabled $True}

Post comments for any questions.

No comments:

Post a Comment

Google+ Followers

Blog Archive