A parameter cannot be found that matches parameter name "Sources"

Roger Roger 7,181 Reputation points
2024-12-16T06:22:19.8933333+00:00

Hi All

i am trying to remove hold from a mailbox from powershell i am getting error please guide me.

A parameter cannot be found that matches parameter name "Sources"

Get-Mailbox ******@contoso.com | Select-Object -ExpandProperty InPlaceHolds
UniH12e6c9yy-j8e2-1j3f-k123-123u98hjkl78

$CaseHold = Get-CaseHoldPolicy 12e6c9yy-j8e2-1j3f-k123-123u98hjkl78
Get-ComplianceCase $CaseHold.CaseID | FL Name
$CaseHold | Fl Name,ExchangeLocation

Name: MyHold-01012024

Set-MailboxSearch -Identity "MyHold-01012024" -Sources @{Remove="******@contoso.com"}
Set-MailboxSearch : A parameter cannot be found that matches parameter name "Sources"

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,185 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2024-12-17T07:58:19.43+00:00

    Hi, @Roger Roger

    From the above conversation, I understand that you want to remove a specific user from an in-place hold. From your reply, it is not surprising that your error is to be expected.

    The term '******@contoso.com' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    This error message indicates that ******@contoso.com is being interpreted as a command, not a string. To fix this, you need to put ******@contoso.com in quotation marks to make sure it's correctly recognised as a string. However, it is important to note that this command does not meet your initial needs. Therefore, it is not recommended that you use this command.

    Remove-CaseHoldPolicy : A parameter cannot be found that matches parameter name 'User'.

    According to the official documentation, this error indicates that there is no -User parameter in the Remove-CaseHoldPolicy command. Similarly, the command doesn't meet your need to remove a specific user from the policy.

    In order to achieve your initial needs, you can follow these steps:

    1.The command used in your initial description is correct. Extract the values in the red box. In this case, there are user1 and user2 in the policy.

    User's image

    2.Use the following command to remove user1:

    Set-CaseHoldPolicy -Identity "Policy Name" -RemoveExchangeLocation "user1"
    

    User's image 3.Looking at the policy again, only user2 and user1 have been successfully removed.

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2024-12-16T07:28:29.25+00:00

    Hi, @Roger Roger

    This error is to be expected, as "-sources" is not an argument to "Set-MailboxSearch".

    To remove a mailbox from an In-Place Hold, you should use the Set-MailboxSearch cmdlet and use the -SourceMailboxes parameter instead of -Sources.

    Here are the corrected commands:

    Set-MailboxSearch -Identity "MyHold-01012024" -SourceMailboxes @{Remove=******@contoso.com}
    

    However, it's important to note that the -MailboxSearch cmdlet is retired in Exchange Online PowerShell. If you continue to use the command above, you may not get the expected output. Please use the -ComplianceSearch cmdlets in the Security & Compliance PowerShell.

    More information can be found Set-MailboxSearch (ExchangePowerShell) | Microsoft Learn


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.