Wildcards are only supported at the end of a string, not the beginning, or in between. So you'll probably have to run multiple searches to cover all possibilities.
Search-Mailbox for character strings/patterns?
I have always thought this was easily doable using wildcard *.
Basically., I want to search for a character pattern, either numbers or letters, for example: I want to find all emails in user John Doe's mailbox that contain the number string of 1234. Not only exact matches of 1234, but any instances including, for example 012345, A12345, 20012345, aaa1234bbb, etc. I want the query to find the specified string anywhere. I would think this would be easy, but apparently I cant find a method that works.
This is the base starting point I have tried: Search-Mailbox -identity "jdoe" -SearchQuery '"1234" AND received:02/01/21..02/18/21' -TargetMailbox "domain\someuser" -TargetFolder "search-test"
I have also tried subject:"1234" , body:"1234" , no quotes, parentheses, asterisks before and after the string, etc. I cant seem to get it to work. What am I missing. It seems like the asterisks wildcard works for some stuff, but I can't get it to work here.
How can I match patterns for both numbers and letters?
Exchange Exchange Server Management
2 answers
Sort by: Most helpful
-
Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
2021-02-18T18:35:43.2+00:00 -
Eric Yin-MSFT 4,396 Reputation points
2021-02-19T03:00:24.427+00:00 I think the search engine is not smart enough to do that, I've tested some situation but the confirmed search-able situation should be:
Your message: (space) text (space)
And your searchquery: "text" or "text". (when we type wildcard in this forum, it makes words italic)
So I'm afraid the current search fuction could not work as you expect.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.