Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

search-maillbox exact search criteria

Posted on 2013-06-10
5
Medium Priority
?
409 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
  • 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

A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Phishing emails are a popular malware delivery vehicle for attack.  While there are many ways for an attacker to increase the chances of success for their phishing emails, one of the most effective methods involves spoofing the message to appear to …
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

886 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