If this is on-prem, you can directly export to ST using New-MailboxExportRequest.
If this is online, you can use Search-Mailbox as indicated. However, Search-Mailbox will be deprecated in favor of New-ComplianceSearch. Using ExchangeLocation, and when search is finished, you can export results to a PST. Easiest is through the Purview (compliance) portal, or use New-ComplianceSearchAction -SearchName ... -Export -Format FxStream -ArchiveFormat SinglePst. Need to retrieve the exported PST through portal though.
Search for emails in mailbox

Hi, I need to search for emails in an user mailbox and then export these emails into pst file
It needs to have following
search of emails to be as follows,
All emails between User 1 and User 2
That include either in the subject, attachment name or body of the email the following names/terms
Word 1
Word 2
Between 02 Feb 2022 and 05 Mar 2022
What is the best way to do this, Do I need to use powershell to search mailbox or attached it to my outlook. (This mailbox is over 1.5TB)
I did try to use the search function but i'm not sure if this is the correct way or not
Search-mailbox -Identity User2022@Domain.com -SearchQuery '(
(BODY:"Word 1" OR "Word 2" OR "Word 3")
OR
(Subject:"Word 1" OR "Word 2" OR "Word 3")
OR
(attachment:"Word 1" OR "Word 2" OR "Word 3")
)
AND
(
(FROM:User 1 OR User 2 OR User 3)
OR
(TO:User 1 OR User 2 OR User 3)
)
AND
(SENT:05/02/2022..07/03/2022)
' -TargetMailbox "User@domain.com" -TargetFolder "ProjectHamilton" -LogLevel Full -whatif
3 answers
Sort by: Most helpful
-
Michel de Rooij 1,521 Reputation points MVP
2022-06-28T11:00:57.223+00:00 KyleXu-MSFT 25,746 Reputation points2022-06-29T03:41:46.253+00:00 Based on my testing, there exist some issue when use "Subject" and "Body" in the same search. So, I would suggest you create two search for them:
New-MailboxExportRequest -Mailbox UserA -ContentFilter "(Received -Gt '05/01/2018') -and (Received -lt '06/30/2022') -and ((Subject -like '*sub*') -or (Subject -like '*Test*'))" -FilePath "\\EXCH\Shared\1.pst" New-MailboxExportRequest -Mailbox UserA -ContentFilter "(Received -Gt '05/01/2018') -and (Received -lt '06/30/2022') -and ((Body -like '*body*') -or (Body -like '*test*'))" -FilePath "\\EXCH\Shared\2.pst"
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.