Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

powershell script to query and delete emails

Posted on 2016-10-18
8
Medium Priority
?
161 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 

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 2000 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

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

New style of hardware planning for Microsoft Exchange server.
I don't pretend to be an expert at this, but I have found a few things that are useful. I hope that sharing them here will help others, so they will not have to face some rather hard choices. Since I felt this to be a topic of enough importance and…
In this video we show how to create an email address policy 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…
To show how to generate a certificate request 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 Servers >> Certificates…
Suggested Courses

610 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