none
Mailbox Search Queries with Multiple Criteria RRS feed

  • Question

  • Hi all,

    I need to search mailboxes on two criteria (sender and subject).  I'm confused how to do this in one command.  For example:

    search-mailbox -identiy UserA -searchquery "SenderAddress:UserB" "subject:Test" -EstimateResultOnly

    I can't simply have the sender and subject options next to eachother, it gives and error.  I tried putting "and" between them and that didn't work.  Anyone know the right syntax for this?

    Thursday, February 16, 2012 2:31 PM

Answers

  • Hi,

    I´m away from my testing environment but I think this command would work:

    search-mailbox -identiy UserA -searchquery "'SenderAddress:UserB' AND 'subject:Test'" -EstimateResultOnly

    Hope this works.

    Some more detailed information you will find here:

    http://technet.microsoft.com/en-us/library/dd353189.aspx


    regards Thomas Paetzold visit my blog on: http://sus42.wordpress.com


    • Edited by Peddy1st Thursday, February 16, 2012 8:29 PM
    • Proposed as answer by Zi Feng Monday, February 20, 2012 4:49 AM
    • Marked as answer by Zi Feng Thursday, February 23, 2012 2:03 AM
    Thursday, February 16, 2012 8:27 PM

All replies

  • Hi,

    I´m away from my testing environment but I think this command would work:

    search-mailbox -identiy UserA -searchquery "'SenderAddress:UserB' AND 'subject:Test'" -EstimateResultOnly

    Hope this works.

    Some more detailed information you will find here:

    http://technet.microsoft.com/en-us/library/dd353189.aspx


    regards Thomas Paetzold visit my blog on: http://sus42.wordpress.com


    • Edited by Peddy1st Thursday, February 16, 2012 8:29 PM
    • Proposed as answer by Zi Feng Monday, February 20, 2012 4:49 AM
    • Marked as answer by Zi Feng Thursday, February 23, 2012 2:03 AM
    Thursday, February 16, 2012 8:27 PM
  • Hi,

    any updates?


    regards Thomas Paetzold visit my blog on: http://sus42.wordpress.com

    Friday, February 17, 2012 9:48 PM
  • Hi

    Did you try what Peddy said?

    Cheers

    Zi Feng


    Zi Feng

    TechNet Community Support

    Monday, February 20, 2012 4:49 AM
  • I realize this is really old but the only response also has bad syntax. Here is a complete example with correct syntax:

    Search-Mailbox -Identity "User Alpha" -SearchQuery 'From:Sender@company.com Subject:"Multiple word test"' -TargetMailbox "Search Mailbox" -TargetFolder "Search Folder" -LogLevel Full

    Items to note about syntax:

    • Use a single quote for the beginning and end of the whole search query string
    • Use double quotes to surround parameters that require multiple words
    • The use of the word AND between query items is optional (tested on Exchange 2010) so you will notice I didn't use it

    Hope that helps anyone else who looks this up.


    Michael Wigle

    • Proposed as answer by reprac Friday, May 5, 2017 4:34 PM
    Thursday, February 9, 2017 6:20 PM
  • Not only is the use of "AND" optional, it will often break the query.

    Blog / Twitter

    Friday, May 5, 2017 4:35 PM