Share via

In-Place hold Error while adding account using Powershell

Anonymous
2016-07-13T20:40:09+00:00

I have a script that adds users who are moved to O365 on in-place hold.

It fetches the existing source mailboxes in the search and then add new the user's identity to the end of it.

Script:       

        $InPlaceHoldMailboxes = (Get-MailboxSearch $user.extensionAttribute11).sourceMailboxes

$mailbox = get-mailbox $($user.msExchExtensionCustomAttribute1)

$mailbox | %{$InPlaceHoldMailboxes += $_.Identity

Set-MailboxSearch $user.extensionAttribute11 -SourceMailboxes $InPlaceHoldMailboxes -InPlaceHoldEnabled $true -Force

}

Whenever, I run the script it gives me an error. However, console works fine. 

Error:

The operation requires unique source objects, but multiple objects have been found for one of the source mailboxes. Please use either the LegacyExchangeDN or the GUID since they should be unique. SecondObject: <Name of a mailbox>

The identity is unique for all the mailboxes. The second object that is displayed in the error is also unique. The second object is same in most cases.

Is there a better way of scripting it? What does Set-MailboxSearch look for a mailbox - displayname, identity, etc. that could be matching?

Can someone please help me out?

Microsoft 365 and Office | Subscription, account, billing | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2016-07-15T09:32:16+00:00

Hi Bhavpreet,

Thanks for your reply.

If console means EAC (Exchange admin center), it uses the command below to put mailboxes on In-Place hold:

New-MailboxSearch "Hold-CaseId01" -SourceMailboxes "@contoso.com" -InPlaceHoldEnabled $true

You can see the source mailbox is a certain email address which is an unique object. More information can be found inthis article.

Feel free to let us know if you have other concerns about the command mentioned in the article above.

Regards,

Larry

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-07-16T09:42:40+00:00

    Hi Bhavpreet,

    Let us know if you need further assistance about the command mentioned in my previous post.

    Regards,

    Larry

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-07-14T19:55:55+00:00

    Hi Larry,

    Thanks for your response. I posted the same in the Script forum.

    I also wants to know, why the console works fine? It adds the user without giving an error. Which command does it uses in the backend?

    Regards,

    Bhavpreet

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-07-14T05:17:45+00:00

    Hi Bhavpreet,

    The Identify parameter specifies the display name of the mailbox search results, so please make sure no duplicate display names of those mailboxes. In addition, I’d like to explain that we cannot directly provide technical support regarding customized scripts because this forum focuses on Office 365 for Business Online services. So we suggest you post in the Scripts Forum for dedicated assistance if the display names are indeed different.

    Regards,

    Larry

    Was this answer helpful?

    0 comments No comments