locked
Export-Mailbox -ContentKeywords RRS feed

  • Question

  • Hi Everyone,

    I'm running the following command on a number of mailboxes in an attempt to export mails with specific key words from the users mailboxes:

    Get-Mailbox -Identity <ALIAS>| Export-Mailbox -TargetMailbox <TARGET_ALIAS> -TargetFolder \FOLDERNAME -StartDate 01/04/2014 -EndDate 12/12/2014 -AllContentKeywords:'word1','word2','word3'....... -BadItemLimit 100

    In total I have a string of about twenty words.  If I run that command against two of the mailboxes in question I end up with an empty bunch of folders in the target mailbox.  As a result I questioned the validity of either the command or the databases index(s).  I proceeded to rebuild the index(s) on the DB's in question after reading the following blog article:

    http://blogs.technet.com/b/richardroddy/archive/2009/11/18/export-mailbox-using-a-filter-does-not-export-anything.aspx

    I have now re-ran the command and still I get nothing.  However as the export run's I can access the mailbox via OWA and can see mails appearing in the target folder.  If I search the target folder within OWA I can even find mails with my keywords appearing in them.  However by the time the powershell command has completed the target folder is empty and a get-mailboxstatistics confirms this.  As a test I tried shrinking my key words to only three words, voila!  I now have a mailbox with 666 items in it according to Get-MailboxStatistics.

    Can anyone see anything wrong with the overall command?  I'm assuming if the index was corrupted again after rebuilding it then I would not get any results.  I'm little bit puzzled!

    Any help or ideas would be greatly appreciated.

    Kind Regards

    Chris

    Friday, April 17, 2015 10:07 AM

Answers

  • Hi Martin,

    Thanks ever so much for taking the time to reply.  I tested your suggestion and it indeed works:

    [PS] C:\Program Files\Microsoft\Exchange Server\Scripts>'Word1','Word2','Word3','Word4','Word5','Wor
    d6','Word7','Word8','Word9','Word10','Word11','Word12','Word13','Word14','Word15','Word16','Word17',
    'Word18','Word19','Word20'
    Word1
    Word2
    Word3
    Word4
    Word5
    Word6
    Word7
    Word8
    Word9
    Word10
    Word11
    Word12
    Word13
    Word14
    Word15
    Word16
    Word17
    Word18
    Word19
    Word20

    A quick question if I may though.  Surely adding all of these into a variable achieves the same result as listing them out individually?

    In terms of how the filtering functionality works, my perception is that if an email contains any word in this defined list it will be exported to the destination.  The way my searches produce nothing almost suggests that all words have to be present for the email to be exported, it appears that if functions as an AND rather than an OR.  Is that your perception of how the cmdlet functions?

    Kind Regards

    Chris

    • Marked as answer by valleydoofer Wednesday, April 22, 2015 7:38 AM
    Friday, April 17, 2015 2:55 PM
  • Hi,

    One thing I should mention is that the buffer for the AllContentKeywords parameter is 32 kb. But 32 kb should be large enough for your twenty words.

    I confirm the function of search is an “OR”. What my concern is that how many mailboxes are you searching an the same time? Are there any errors in the EMS after running that command? And if the data you want to export is too large(exceed the limit of target mailbox event database), then this phenomenon will happen.

    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 valleydoofer Wednesday, April 22, 2015 7:38 AM
    Wednesday, April 22, 2015 3:01 AM

All replies

  • I'm going to assume you have Exchange 2007, or I'd suggest you try a Mailbox Export Request using the ECP. Since we're working with Exchange 2007, I'm going to assume the keyword list is what's giving fits. What happens if you remove everything in the command but the content keyword list?  So for instance, if your command is:

    Get-Mailbox -Identity <ALIAS>| Export-Mailbox -TargetMailbox <TARGET_ALIAS> -TargetFolder \FOLDERNAME -StartDate 01/04/2014 -EndDate 12/12/2014 -AllContentKeywords:'Word1','Word2','Word3','Word4','Word5','Word6','Word7','Word8','Word9','Word10','Word11','Word12','Word13','Word14','Word15','Word16','Word17','Word18','Word19','Word20' -BadItemLimit 100

    What happens if you run just the keywords?

    'Word1','Word2','Word3','Word4','Word5','Word6','Word7','Word8','Word9','Word10','Word11','Word12','Word13','Word14','Word15','Word16','Word17','Word18','Word19','Word20'

    You should get a list of the words.  If this still works, have you tried putting your list of words into a variable?

    $WrdLst = 'Word1','Word2','Word3','Word4','Word5','Word6','Word7','Word8','Word9','Word10','Word11','Word12','Word13','Word14','Word15','Word16','Word17','Word18','Word19','Word20'

    Then you add this to your command, instead of the individual words.  This way, you can add them sequentially until you find where things break.  Then remove that word and add the next to see if it's an issue with the word itself.

    • Edited by Will Martin, PFE Friday, April 17, 2015 2:29 PM
    • Proposed as answer by Lynn-Li Tuesday, April 21, 2015 8:39 AM
    Friday, April 17, 2015 2:28 PM
  • Hi Martin,

    Thanks ever so much for taking the time to reply.  I tested your suggestion and it indeed works:

    [PS] C:\Program Files\Microsoft\Exchange Server\Scripts>'Word1','Word2','Word3','Word4','Word5','Wor
    d6','Word7','Word8','Word9','Word10','Word11','Word12','Word13','Word14','Word15','Word16','Word17',
    'Word18','Word19','Word20'
    Word1
    Word2
    Word3
    Word4
    Word5
    Word6
    Word7
    Word8
    Word9
    Word10
    Word11
    Word12
    Word13
    Word14
    Word15
    Word16
    Word17
    Word18
    Word19
    Word20

    A quick question if I may though.  Surely adding all of these into a variable achieves the same result as listing them out individually?

    In terms of how the filtering functionality works, my perception is that if an email contains any word in this defined list it will be exported to the destination.  The way my searches produce nothing almost suggests that all words have to be present for the email to be exported, it appears that if functions as an AND rather than an OR.  Is that your perception of how the cmdlet functions?

    Kind Regards

    Chris

    • Marked as answer by valleydoofer Wednesday, April 22, 2015 7:38 AM
    Friday, April 17, 2015 2:55 PM
  • I've checked on the function and it is supposed to be an OR.  As for a variable working where the individual items didn't, I've found this at times, so I figured it would be worth a shot.  Yes, they are both supposed to work the same, but I've seen failures in some of my own filtering when items are listed separately, but when I list them in a variable (which becomes, of course, an array of string items), it works.  Never hurts to try ...
    Friday, April 17, 2015 3:25 PM
  • Hi,

    One thing I should mention is that the buffer for the AllContentKeywords parameter is 32 kb. But 32 kb should be large enough for your twenty words.

    I confirm the function of search is an “OR”. What my concern is that how many mailboxes are you searching an the same time? Are there any errors in the EMS after running that command? And if the data you want to export is too large(exceed the limit of target mailbox event database), then this phenomenon will happen.

    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 valleydoofer Wednesday, April 22, 2015 7:38 AM
    Wednesday, April 22, 2015 3:01 AM
  • Hi Lynn-Li,

    Thank you ever so much for following up on this, really interesting to understand that there is a 32KB buffer constraint there although I'm confident you are correct in that won't be a constraint in this example.

    In terms of the command and errors I have only been running this against one mailbox at a time and no errors occur within the EMS.  I will re-run the command but output to a PST to see what data I recover, if successful this will at least then point to an issue with the target mailbox that I can then look into further.

    Kind Regards

    Chris

    Wednesday, April 22, 2015 7:37 AM