Skip to content

Instantly share code, notes, and snippets.

@mitchellurgero
Created May 31, 2018 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchellurgero/6bc3218df6fb7ef1904ce636590e444b to your computer and use it in GitHub Desktop.
Save mitchellurgero/6bc3218df6fb7ef1904ce636590e444b to your computer and use it in GitHub Desktop.
Search Exchange 2013/2016 for emails and put into a PST file (Powershell!)
# Search All mailbox's on the server:
Get-mailboxserver -identity "SERVERNAME" | search-mailbox -searchquery "Search query as you would type it in Outlook" -targetmailbox "USERNAMEOFTARGETMAILBOX" -TargetFolder "NEWFOLDERTOPUTSEARCHIN" -loglevel full
# Search One mailbox on the server:
search-mailbox -Identity "USERNAME" -searchquery "Search query as you would type it in Outlook" -targetmailbox "USERNAMEOFTARGETMAILBOX" -TargetFolder "NEWFOLDERTOPUTSEARCHIN" -loglevel full
# Explination:
# USERNAMEOFTARGETMAILBOX - The mailbox the search results will be pulled into. (E.G: administrator)
# NEWFOLDERTOPUTSEARCHIN - The folder to put the search results in. (E.G: New Folder For Emails)
# Export the above to PST:
New-MailboxExportRequest -Mailbox "USERNAMEOFTARGETMAILBOX" -IncludeFolders "NEWFOLDERTOPUTSEARCHIN" -FilePath \\localhost\D$\path\to\store\pst
## Be sure to change filepath to match your needs in the export!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment