locked
Search-Mailbox RRS feed

  • Question

  • Hi experts

    Please help me correct the below syntaxes

    To search a mailbox with subject: test123456789

    Search-Mailbox -Identity "user1@mydomain.com" -SearchQuery 'Subject:"test123456789"' -TargetMailbox "administrator@mydomain.com" -TargetFolder "searchresults" -LogOnly -LogLevel Full


    To Search a mailbox with subject:test123456789 received from abc@gmail.com

    Search-Mailbox -Identity user1@mydomain.com -SearchQuery ‘Subject:test123456789 AND From:abc@gmail.com AND Received:"10/10/2018..10/20/2018"’ -TargetMailbox "administrator@mydomain.com" -TargetFolder "searchresults" -LogOnly -LogLevel Full

    ======================================================

    To Search a mailbox with email body REJECTED

    Get-Mailbox -Identity user1@mydomain.com| Search-Mailbox -SearchQuery Received:"10/10/2018 00.00..10/20/2018 23:59" -TargetMailbox <REJECTED> -TargetFolder "searchresults" -LogOnly -LogLevel Full

    To Search a mailbox with email body REJECTED received from abc@gmail.com
    Get-Mailbox -Identity user1@mydomain.com | Search-Mailbox -SearchQuery {from:abc@gmail.com AND Received:"10/10/2018 00.00..10/20/2018 23:59"} -TargetMailbox <rejected> -TargetFolder "searchresults" -LogOnly -LogLevel Full


    Thursday, November 1, 2018 5:43 PM

Answers

  • Hi,

    Based on my test, the commands used to search messages by subject run successfully.

    For the second requirement, what do you mean by “Search a mailbox with email body REJECTED”? If you want to search messages containing specific word REJECTED, you can run the command below.
    Get-Mailbox -Identity user1@mydomain.com | Search-Mailbox -SearchQuery ‘REJECTED' -TargetMailbox <target mailbox> -TargetFolder <target folder> -LogOnly -LogLevel Full
    

    Regards,

    Dawn Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Proposed as answer by Dawn Zhou Tuesday, November 13, 2018 1:36 AM
    • Marked as answer by Risingflight Saturday, November 24, 2018 7:20 AM
    Friday, November 2, 2018 9:02 AM
  • Hi,

    The single quotes should be placed in the end of the search query, and the receive time should be "00:00". Based on my test, the following command works.

    Get-Mailbox -Identity user1@mydomain.com| Search-Mailbox -SearchQuery 'Body:"*REJECTED*" AND Received:"10/10/2018 00:00..10/20/2018 23:59"' -TargetMailbox "administrator@mydomain.com" -TargetFolder "searchresults" -LogOnly -LogLevel Full

    Regards,

    Dawn Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Proposed as answer by Dawn Zhou Thursday, November 15, 2018 9:53 AM
    • Marked as answer by Risingflight Saturday, November 24, 2018 7:20 AM
    Monday, November 12, 2018 9:57 AM

All replies

  • Before we check syntax etc. what results are you getting for your searches? 

    Search, Recover, Export Mailboxes, Contacts, Calendars, Tasks from ALL versions of Exchange Offline EDB's, On-Premises Exchange Databases & Office 365. Export, Migrate/Recover into On-Premises Exchange Server, Office 365 with Lucid8's DigiScope

    Thursday, November 1, 2018 8:53 PM
  • Hi,

    Based on my test, the commands used to search messages by subject run successfully.

    For the second requirement, what do you mean by “Search a mailbox with email body REJECTED”? If you want to search messages containing specific word REJECTED, you can run the command below.
    Get-Mailbox -Identity user1@mydomain.com | Search-Mailbox -SearchQuery ‘REJECTED' -TargetMailbox <target mailbox> -TargetFolder <target folder> -LogOnly -LogLevel Full
    

    Regards,

    Dawn Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Proposed as answer by Dawn Zhou Tuesday, November 13, 2018 1:36 AM
    • Marked as answer by Risingflight Saturday, November 24, 2018 7:20 AM
    Friday, November 2, 2018 9:02 AM
  • for example, user1 has received an email and in the email body the word rejected is mentioned. so i want to search by the word rejected in the email body if it is present, i am using the below syntaxes

    Get-Mailbox -Identity user1@mydomain.com| Search-Mailbox -SearchQuery Received:"10/10/2018 00.00..10/20/2018 23:59" -TargetMailbox <REJECTED> -TargetFolder "searchresults" -LogOnly -LogLevel Full

    To Search a mailbox with email body REJECTED received from abc@gmail.com
    Get-Mailbox -Identity user1@mydomain.com | Search-Mailbox -SearchQuery {from:abc@gmail.com AND Received:"10/10/2018 00.00..10/20/2018 23:59"} -TargetMailbox <rejected> -TargetFolder "searchresults" -LogOnly -LogLevel Full


    Sunday, November 4, 2018 2:21 PM
  • Hi,

    OK. So the word "rejected" should be placed in the search query other than target mailbox. You can try the command I provided above.

    Regards,

    Dawn Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Tuesday, November 6, 2018 9:59 AM
  • i have not tested the below two syntaxes, but i belive they shud work

    Get-Mailbox -Identity user1@mydomain.com| Search-Mailbox -SearchQuery ‘Body:"*REJECTED*"' AND Received:"10/10/2018 00.00..10/20/2018 23:59" -TargetMailbox "administrator@mydomain.com" -TargetFolder "searchresults" -LogOnly -LogLevel Full

    Get-Mailbox -Identity user1@mydomain.com| Search-Mailbox -SearchQuery ‘Body:"*REJECTED*"' AND From:abc@gmail.com AND Received:"10/10/2018 00.00..10/20/2018 23:59" -TargetMailbox "administrator@mydomain.com" -TargetFolder "searchresults" -LogOnly -LogLevel Full


    Friday, November 9, 2018 10:05 AM
  • Hi,

    The single quotes should be placed in the end of the search query, and the receive time should be "00:00". Based on my test, the following command works.

    Get-Mailbox -Identity user1@mydomain.com| Search-Mailbox -SearchQuery 'Body:"*REJECTED*" AND Received:"10/10/2018 00:00..10/20/2018 23:59"' -TargetMailbox "administrator@mydomain.com" -TargetFolder "searchresults" -LogOnly -LogLevel Full

    Regards,

    Dawn Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Proposed as answer by Dawn Zhou Thursday, November 15, 2018 9:53 AM
    • Marked as answer by Risingflight Saturday, November 24, 2018 7:20 AM
    Monday, November 12, 2018 9:57 AM