none
Search-Mailbox not working RRS feed

  • Question

  • Hi

    I am using Exchange 2010 power shell to search mailbox but I am getting below error.

    [PS] C:\Windows\system32>Search-Mailbox -Identity "AUser" -SearchQuery "Received -lt '31/10/2015'"
    The target mailbox or .pst file path is required.
    At line:1 char:1
    +  <<<< Search-Mailbox -Identity "AUser" -SearchQuery "Received -lt '31/10/2015'"
        + CategoryInfo          : InvalidArgument: (:) [], ArgumentException
        + FullyQualifiedErrorId : 78F52C6B

    What am I doing wrong? My locale is UK (dd/mm/yyyy).

    Thanks

    Regards


    • Edited by Y a h y a Wednesday, April 27, 2016 1:51 PM
    Wednesday, April 27, 2016 1:51 PM

Answers

  •  I have an admin user AUser which I am also logged in as. I need to search this user's emails prior to 31/10/2015 in his inbox for deletion.

    Hi,

    We cannot identity the specific folder to search. To delete the message in the specific folder, retention policy is a better choice.

    The TargetMailbox parameter specifies the identity of the destination mailbox where search results are copied.

    The TargetFolder parameter specifies a folder name in which search results are saved in the target mailbox. The folder is created in the target mailbox upon execution.

    Since you are going to delete these messages, then use DeleteContent cmdlet. If you want to copies these messages for backup, then you add TargetMailbox parameter with TargetFolder. If you don't want these messages anymore, then just add DeleteContent parameter.

    Search-mailbox -identity "AUser" -searchquery {Received:"31/10/2015"} -DeleteContent

    Refer to this document for more information

    https://technet.microsoft.com/en-us/library/ff459253%28v=exchg.141%29.aspx

    Best Regards.


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com

    Lynn-Li
    TechNet Community Support

    • Marked as answer by Y a h y a Thursday, April 28, 2016 8:49 PM
    Thursday, April 28, 2016 7:55 AM

All replies

  • Hi

    You have to specify the target mailbox at the end to complete the command

    Try

    Search-mailbox -identity "hhhh" -searchquery {Subject:"test" AND Received:"31/10/2015"} -targetmailbox "dddd" -targetfolder "searchresults" -logonly -loglevel full

    Thanks

    NS

    Wednesday, April 27, 2016 2:19 PM
  • Hi

    I am not getting this. I have an admin user AUser which I am also logged in as. I need to search this user's emails prior to 31/10/2015 in his inbox for deletion. How do I go about doing it?

    [PS] C:\Windows\system32>Search-mailbox -identity "AUser" -searchquery {Received -lt "31/10/2015"} -targetmailbox "AUser" -targetfolder "inbox" -logonly
    
    WARNING: The source mailbox 'Server Admin' will not be searched because it is the target mailbox. The source mailbox
    cannot be used as the target mailbox.

    Thanks

    Regards

    Wednesday, April 27, 2016 4:06 PM
  • You need to pick another mailbox as the target. This is where it is going to send the search results.

    Search-Mailbox

    https://technet.microsoft.com/en-us/library/dd298173(v=exchg.160).aspx


    www.SuperTekBoy.com | Find me on Twitter | LinkedIn

    Wednesday, April 27, 2016 4:58 PM
  •  I have an admin user AUser which I am also logged in as. I need to search this user's emails prior to 31/10/2015 in his inbox for deletion.

    Hi,

    We cannot identity the specific folder to search. To delete the message in the specific folder, retention policy is a better choice.

    The TargetMailbox parameter specifies the identity of the destination mailbox where search results are copied.

    The TargetFolder parameter specifies a folder name in which search results are saved in the target mailbox. The folder is created in the target mailbox upon execution.

    Since you are going to delete these messages, then use DeleteContent cmdlet. If you want to copies these messages for backup, then you add TargetMailbox parameter with TargetFolder. If you don't want these messages anymore, then just add DeleteContent parameter.

    Search-mailbox -identity "AUser" -searchquery {Received:"31/10/2015"} -DeleteContent

    Refer to this document for more information

    https://technet.microsoft.com/en-us/library/ff459253%28v=exchg.141%29.aspx

    Best Regards.


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com

    Lynn-Li
    TechNet Community Support

    • Marked as answer by Y a h y a Thursday, April 28, 2016 8:49 PM
    Thursday, April 28, 2016 7:55 AM
  • Hi Lynn-Li

    This worked nicely;

    Search-mailbox -identity "AUser" -searchquery Received:<"31/12/2015" -DeleteContent
    Many thanks

    Regards

    Thursday, April 28, 2016 8:50 PM