Created
June 26, 2018 21:39
-
-
Save mitchellurgero/45b52fd044a67d9a768b507a7fa78a6d to your computer and use it in GitHub Desktop.
Search mailbox in Exchange 2013/2016 for keywords, save to a targetMailbox then export PST.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Search Mailbox's for given keywords | |
# | |
# Make sure the targetMailbox exists, if the folderName folder does not that will be created automatically. | |
# | |
# | |
# Made by Mitchell Urgero | |
# | |
# | |
# For Exchange 2013/2016 | |
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; | |
$idents = "" # username's of mailboxes you want to search EX: $idents = "user1","user2","user3" | |
$targetMailbox = "" # Mailbox where to save results (before export to PST) | |
$folderName = "" # Folder in TargetMailbox to put the results (before export to PST) | |
$searchTerm = "" # search term to use in idents mailbox(s) (same as what you would use in outlook) | |
$resultPath = "" # UNC path to export the PST to | |
foreach($i in $idents){ | |
Write-Host "Searching $i" | |
search-mailbox -Identity "$i" -searchquery "$searchTerm" -targetmailbox "$targetMailbox" -TargetFolder "$folderName" -loglevel full | |
} | |
New-MailboxExportRequest -Mailbox "$targetMailbox" -IncludeFolders "$folderName" -FilePath "$resultPath" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment