• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

powershell script to query and delete emails

Is there a Powershell script to query and delete emails by subject? If someone sends a bad email to a multiple large distribution group i like to search and remove based on subject.
0
CiscoAzn
Asked:
CiscoAzn
  • 4
  • 4
1 Solution
 
AkhaterCommented:
if you are talking about exchange 2010 and newer here is what you want
https://technet.microsoft.com/en-us/library/ff459253(v=exchg.160).aspx

make sure to pick the exchange version corresponding to the one you have
0
 
CiscoAznAuthor Commented:
This is for Exchange 2010. The link you sent me is for Exchange 2016.
0
 
AkhaterCommented:
:) this is for all exchange versions, just pick the one you want on top of the article

anyway here you go https://technet.microsoft.com/en-us/library/ff459253(v=exchg.141).aspx

2016-10-18-19_53_12-Use-Mailbox-Sear.png
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
CiscoAznAuthor Commented:
In the Exchange 2010 version it only shows the search for a mailbox not for the entire org and that's what i'm looking for.
0
 
AkhaterCommented:
It is the same thing

Get-Mailbox | search-mailbox -deletecontent

Will do it for all mailboxes
0
 
CiscoAznAuthor Commented:
Thanks Akhater but how do you get a count of the total emails that it query and the total emails that it found before deleting it?
0
 
AkhaterCommented:
If you run the same command with -TargetFolder  -TargetMailbox parameters instead of the deletecontent you will know exactly which emails are going to be deleted


or you can run a simulation with the -DeleteContent with the -WhatIf parameter
0
 
CiscoAznAuthor Commented:
Sorry for the late response but thank you for your assistance.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now