1 year ago

#383671

test-img

SeeShellRun

Using variable with New-MailboxSearch

Trying to use a variable that contains multiple source mailboxes for the New-MailboxSearch cmdlet, looks like I need to find a way to use a variable without it inserting double quotes, as I get an error when using a variable the normal way. Example code below..

$SourceMailboxes = "user1@domain.com,user2@domain.com"
New-MailboxSearch -Name $Name -SourceMailboxes $SourceMailboxes

This gives me the error message "The specified user "user1@domain.com,user2@domain.com" is not found", because it is trying to resolve it as all one user due to the double quotes.

If I enter them manually the correct format works without the double quotes, as seen below..

New-MailboxSearch -Name $Name -SourceMailboxes user1@domain.com,user2@domain.com

I need to find a way to use the variable without it inserting the double quotes it looks like. Haven't found a way to do this yet.

powershell

exchange-server

0 Answers

Your Answer

Accepted video resources