Solved

powershell script to query and delete emails

Posted on 2016-10-18
8
77 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Are your AD admin tools letting you down?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Find out what you should include to make the best professional email signature for your organization.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

726 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