Hello all,
I am trying to write a script that will automatically add new members to our mailbox search on Office 365. The problem is I do not want the Set-MailboxSearch cmdlet to overwrite existing members within the search (I only want it to add new members). I have tried to get around this by doing the following but I am getting issues because I am mixing datatypes and do not know how to solve it.
$MailboxSearch = Get-MailboxSearch "In-Place Hold - Indefinite"
$O365 = Get-DynamicDistributionGroup -Identity O365Users@wates.co.uk
$Users = Get-Recipient -RecipientPreviewFilter $O365.RecipientFilter -ResultSize Unlimited
$MailboxSearch.SourceMailboxes += $Users
Set-MailboxSearch “In-Place Hold - Indefinite” -SourceMailboxes $MailboxSearch.SourceMailboxes
I know why I get the error because I am trying to combine two lists of different data types but do not know how to resolve it:
Cannot process argument transformation on parameter 'SourceMailboxes'. Cannot convert value
"System.Collections.ArrayList" to type
"Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter[]". Error: "Cannot convert value
"Morek, Krystian" to type "Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter". Error:
"Cannot convert hashtable to an object of the following type:
Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter. Hashtable-to-Object conversion is not
supported in restricted language mode or a Data section.""
+ CategoryInfo : InvalidData: (:) [Set-MailboxSearch], ParameterBindin...mationExcept
ion
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-MailboxSearch
+ PSComputerName : outlook.office365.com
Thanks for any help you can provide.