Solved

powershell script to query and delete emails

Posted on 2016-10-18
8
58 Views
Last Modified: 2016-11-09
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
Comment
Question by:CiscoAzn
  • 4
  • 4
8 Comments
 
LVL 49

Expert Comment

by:Akhater
ID: 41848659
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
 

Author Comment

by:CiscoAzn
ID: 41848663
This is for Exchange 2010. The link you sent me is for Exchange 2016.
0
 
LVL 49

Expert Comment

by:Akhater
ID: 41848670
:) 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:CiscoAzn
ID: 41848801
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
 
LVL 49

Expert Comment

by:Akhater
ID: 41848826
It is the same thing

Get-Mailbox | search-mailbox -deletecontent

Will do it for all mailboxes
0
 

Author Comment

by:CiscoAzn
ID: 41849525
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
 
LVL 49

Accepted Solution

by:
Akhater earned 500 total points
ID: 41849544
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
 

Author Closing Comment

by:CiscoAzn
ID: 41881234
Sorry for the late response but thank you for your assistance.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question