Monday, August 24, 2015

Delete mail in all mailbox

Recently I have faced the email virus issue. It's started from one PC and spread over all mailboxes. 

Now the solution is need to delete that particular mail from all mailboxes, so I have started the below steps,

Below command will delete with particular subject and export to notepad,

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery "(subject:test)" -DeleteContent -Force > C:\deleteoutput.txt

Below command will delete with particular attachment and export to notepad,

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery "(Attachment:test)" -DeleteContent -Force > C:\deleteoutput.txt

Below command will delete with particular attachment & subject and export to notepad,

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery "((subject:test) AND Attachment:test)" -DeleteContent -Force > C:\deleteoutput.txt

 Below command will display only the count item in particular user with particular subject


Search-Mailbox -Identity Aliasname -SearchQuery "(Subject:test)" –EstimateResultOnly

 Below command will display only the count item in particular user with particular attachment 

Search-Mailbox -Identity Aliasname -SearchQuery "(Attachment:test)" –EstimateResultOnly
 

No comments:

Post a Comment