Script to add users to existing Inplace Hold policy in office 365

Dear Team,

1. We have a requiremnt to filter users who are not enabled "in-place eDiscovery & hold " (Ex: all newly added users in office     365 / Exchange 2013) to add to a "in-place eDiscovery & hold" policy named "xyz-365 Days"

2. By doing this, it should not remove existing users in the policy

The follwing are the commands related to this.

New-MailboxSearch "searchname" -SourceMailboxes "user@domain.com" -InPlaceHoldEnabled $true

Set-MailboxSearch "searchname" -sourcemailbox user@domain.com

July 9th, 2015 2:30am

Try this

Get-Mailbox -IncludeLitigationHoldDuration | select alias, Lit* | ? {$_.LitigationHoldEnabled -eq $false} | export-file name.csv

$1 = import-csv name.csv

{foreach ($2 in $1)

$a=$2.alias

{Set-mailbox $a-LitigationHoldEnabled:$true }

Free Windows Admin Tool Kit Click here and download it now
July 9th, 2015 8:01am

Hi,

Why dont you create the mailbox search for all mailboxes? Then all mailboxes will be added to this search including both InPlaceHolds Enabled/Disabled, and all mailboxes will be InPlaceHold Enabled.

I can only filter out the mailboxes with InPlaceHold Enabled.

Get-mailbox resultsieze unlimited | ? {$_.InPlaceHolds -ne $null}

Here is the script to add mailbox to the list.

$search=Get-MailboxSearch -Identity " xyz-365 Days"

$search.sourcemailboxes+="user@contoso.com"

Set-MailboxSearch -Identity " xyz-365 Days" -SourceMailboxes $search.sourcemailboxes

Best Regards.

July 9th, 2015 11:14pm

But what will happen to the mailboxes which are already enabled for inplace hold???

And in your above script, it only adds single mailbox.

But i need to add multiple newly added users to the inplace hold in addition to the existing users

I got the following line in some thread whihc talks about this, whether it hold good?

$InPlaceHoldMailboxes = (Get-MailboxSearch InPlaceHold).sourceMailboxes
Get-Mailbox -ResultSize unlimited | %{$InPlaceHoldMailboxes += $_.Identity
Set-MailboxSearch InPlaceHold -SourceMailboxes $InPlaceHoldMailboxes -InPlaceHoldEnabled $true}

Free Windows Admin Tool Kit Click here and download it now
July 16th, 2015 4:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics