Solved

powershell script to query and delete emails

Posted on 2016-10-18
8
88 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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In-place Upgrading Dirsync to Azure AD Connect
Check out this step-by-step guide for using the newly updated Experts Exchange mobile app—released on May 30.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

689 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