Pages

Showing posts with label exchange. Show all posts
Showing posts with label exchange. Show all posts

October 9, 2015

Deleting Message from Exchange Mailboxes with Powershell



From time to time it may become necessary to search a users mailbox for a message or delete a specific message from a mailbox. Below are a few powershell commands you can use with Exchange 2010 to search a mailbox for a particular email message.



Delete All Messages with a specific subject
get-mailbox -identity "SOURCEMAILBOX" -resultsize unlimited | search-mailbox -SearchQuery "Subject:"SUBJECTSTRING"" -DeleteContent

Delete All messages with a specific attachment
get-mailbox -identity "SOURCEMAILBOX" -resultsize unlimited | search-mailbox -SearchQuery "attachment:FILENAME.DOCX" -DeleteContent

Search Mailbox by subject and date and copy the message out of the source mailbox into the targetmailbox
get-mailbox -identity "SOURCEMAILBOX" -resultsize unlimited |  search-mailbox -SearchQuery "subject:""SUBJECTSTRING"" Sent:"MMDDYYYY" -TargetMailbox DESTINATIONMAILBOX -TargetFolder TARGETFOLDER –LogOnly -LogLevel Full

Search Mailbox by subject and date and copy the message out of the source mailbox into the targetmailbox and then delete the email from source mailbox
get-mailbox -identity "SOURCEMAILBOX" -resultsize unlimited |  search-mailbox -SearchQuery "subject:"SUBJECTSTRING" Sent:"MMDDYYYY" -TargetMailbox DESTINATIONMAILBOX -TargetFolder TARGETFOLDER –LogOnly -LogLevel Full -deletecontent