Tuesday 29 January 2019

Search mailboxes in Exchange server 2013 and delete or move the content to another mailbox

1)
To Search email between 2 specific dates and move the content to another mailbox.
First lets create the following 3 variables and put the values as per your requirements

$Fromdate ="10/01/2018";
$Todate = "01/20/2019";
$date="Received:"+$Fromdate+".."+$Todate

Search-Mailbox v.hili@domain.com -SearchQuery "$date" -TargetMailbox khaaz@domain.com -TargetFolder ToFromHilal

2
Tested: to copy data from one mailbox to another one.
Search-Mailbox v.hil@domain.com -SearchQuery 'Subject:"RDP"' -TargetMailbox khaaz@domain.com -TargetFolder tohilal

3
Tested: To Delete content from a mailbox of a subject.
Search-Mailbox -Identity "khaaz@domain.com" -SearchQuery 'Subject:"sook sook"' -DeleteCon
tent

4
To Search all mailboxes that contain the words country OR province OR districts, and copy the result to khaaz@domain.com mailbox in Country Folder
Get-Mailbox | Search-Mailbox -SearchQuery 'country OR province OR districts' -TargetMailbox khaaz@domain.com -TargetFolder "AllMailboxes-Country" -LogLevel Full

No comments:

Post a Comment