Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

search-maillbox exact search criteria

Posted on 2013-06-10
5
Medium Priority
?
398 Views
Last Modified: 2013-06-12
Hello,

I have a basic script that searches all mailboxes on our exchange server. How can I limit the search criteria to an exact match?

Search-Mailbox -SearchQuery 'Subject: "TEST"', 'Body: "Test"' -targetmailbox "jbuzzetta" -targetfolder "inbox" -logonly -loglevel full

Results for test, testify, retest will all show up.

I'd like to see only TEST.
0
Comment
Question by:susnewyork
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 9

Expert Comment

by:David Carr
ID: 39235787
Check that search is running and has a completed index.  look for Event ID 110 in logs to confirm completion.
Test-ExchangeSearch -Identity user@domain.com

Open in new window

For subject searching syntax should be
Search-Mailbox -SearchQuery subject:"Test" -TargetMailbox Administrator -TargetFolder SearchLogs -LogOnly -LogLevel Full

Open in new window

0
 
LVL 40

Expert Comment

by:Subsun
ID: 39237312
I think what you are taking is the default behavior for Search-mailbox.. You need to add more condition to narrow down your search..
For example..
Search-Mailbox -Identity subsun -SearchQuery 'from:subsuntest AND sent:6/11/2013 AND Subject:"Test mail"' -TargetMailbox Adminmailbox -TargetFolder SearchLogs -LogOnly -LogLevel Full

Open in new window

0
 
LVL 1

Author Comment

by:susnewyork
ID: 39237735
PowerShell can't find exact strings excluding extra string data from the search? That sounds like basic functionality. I'd expect that I'd have to use -like to get the results that subject:"Test" is giving.
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39240942
Search-Mailbox wont suport those operators or any RegEX.. Also the command wont pass any subject propery to pipeline so we cannot filter it..
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39241082
BTB if you are just trying to export the mails then you can try New-MailboxExportRequest with parameter ContentFilter, it allows you to filter the messages based on subject..

Refer :
http://technet.microsoft.com/en-us/library/ff607299(v=exchg.141).aspx
http://technet.microsoft.com/en-us/library/ff601762(v=exchg.141).aspx
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question