search-mailbox -searchquery more than once

Hi All,

I have this powershell script,

search-mailbox  -identity kelly.garcia -searchquery 'Subject:"*Intense Action Required!*"' -SearchQuery sent:yesterday

this gives me an error:

search-mailbox : Cannot bind parameter because parameter 'SearchQuery' is specified more than once. To provide multiple values to parameters that can accept
 multiple values, use the array syntax. For example, "-parameter value1,value2,value3".

hpw do I fix this? also can I enter a date range for example I want to find these emails within the last week only?
Kelly GarciaSenior Systems AdministratorAsked:
Who is Participating?
IvanConnect With a Mentor System EngineerCommented:

you can use AND

Search-Mailbox  -Identity kelly.garcia -SearchQuery "Subject:'*Intense Action Required!*' and 'Sent:yesterday'"

timgreen7077Exchange EngineerCommented:
Ivan is correct. Use the AND operator.

search-mailbox -Identity "username" -SearchQuery 'from:"emailaddress" and subject:"subjectline" and sent:06/02/2015'
 -TargetMailbox "mailbox" -TargetFolder inbox
Kelly GarciaSenior Systems AdministratorAuthor Commented:
this works too:

Search-Mailbox -Identity $mb.alias -SearchQuery {sent:28/02/2018..07/03/2018 Subject:"*RE: Attention (Staff Migration)*" from:""} -deletecontent -force

Open in new window

should I still use the and operator?
timgreen7077Exchange EngineerCommented:
Yes you still will use AND
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.