Link to home
Start Free TrialLog in
Avatar of pramod1
pramod1Flag for United States of America

asked on

office 365, outlook, email protocol

, on occasion we have seen malware delivered to a user’s inbox and we would like to be able to pull those messages out.

Is it possible to have a powershell command that could remove these e-mails based on items like the senders e-mail address and subject?


we have mailboxes in office 365 but we have proof point gateway through which incoming and outgoing emails go
Avatar of FOX
FOX
Flag of United States of America image

Search all mailboxes with powershell and delete based on subject, sender, etc

ref link:  https://www.ntweekly.com/2017/08/14/powershell-code-delete-specific-email-from-all-mailboxes-in-exchange/
Avatar of pramod1

ASKER

how about subject?
Avatar of timgreen7077
timgreen7077

You can use the below cmdlets to search:

Search sender and subject. You can remove either and just search one or the other also.

search-mailbox -Identity "username" -SearchQuery 'from:"senderemail@domain.com" and subject:"HOLA"' -DeleteContent -Confirm:$false -Force
ASKER CERTIFIED SOLUTION
Avatar of timgreen7077
timgreen7077

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pramod1

ASKER

search-mailbox -Identity "username" -SearchQuery 'from:"senderemail@domain.com" and subject:"HOLA"' -DeleteContent -Confirm:$false -Force

it should be $ true or false?