Searching and removing e-mails from the server
There will be times when you as an Exchange administrator would get request to log or delete specific items from the user's mailboxes. The Search-Mailbox
cmdlet helps you to search a mailbox or a group of mailboxes for a specific item, and it also allows you to delete them.
You need to be part of the Mailbox Search and Mailbox Import Export RBAC roles to be able to search and delete messages from a user's mailbox.
The following example searches John Doe's mailbox for e-mails with the subject "Credit Card Statement" and logs the result in the Mailbox Search Log folder in the administrator's mailbox:
Search-Mailbox -Identity "John Doe" -SearchQuery 'Subject:"Credit Card statement"' -TargetMailbox administrator -TargetFolder "MailboxSearchLog" -LogOnly -LogLevel Full
The following example searches all mailboxes for attachments that have "Virus" as the file name and logs it in the Mail box Search log in the administrator's mailbox:
Get-Mailbox -ResultSize...