Solved

Deleting messages based on subject keywords

Posted on 2014-07-18
5
141 Views
Last Modified: 2014-07-21
I am looking to manage size of inboxes by auto deleting messages that have a certain subject line after say 30 days.
0
Comment
Question by:Brazilee
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 40205769
Get-Mailbox -ResultSize Unlimited | Export-Mailbox -ContentKeywords "<subject line here>" -TargetMailbox MyBackupMailbox -StartDate "06/18/2014" -EndDate "07/18/2014" -TargetFolder '<folder Name>' -DeleteContent

Open in new window

0
 
LVL 7

Accepted Solution

by:
Murali Reddy earned 350 total points
ID: 40205983
There are two disadvantages of using above commad
1- exporting contents to a common mailbox, do you really need it?
2- it is exporting and deleting one month's range (-StartDate "06/18/2014" -EndDate "07/18/2014") emails only.


I'd suggest you use search-mailbox with AQS something like,

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery {(subject:<SubjecttoQuery>) AND (Sent:01/01/2000..06/19/2014) AND (Received:01/01/2000..06/19/2014)} -DeleteContent

if you want a copy of it or you want to just log thedetails, use some thing like'

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery {(subject:<SubjecttoQuery>) AND (Sent:01/01/2000..06/19/2014) AND (Received:01/01/2000..06/19/2014)} -TargetMailbox Administrator -TargetFolder SearchLogs -LogOnly -LogLevel Full



## I put some old date top have the range cover all the emails olderthan 30 days. you choose accordingly.

First you use -logonly parameter to see if you are getting the exact results and then proceed to delete.
0
 

Author Comment

by:Brazilee
ID: 40206496
Can I use this command to affect the entire company (information store) rather then one mailbox?
0
 
LVL 29

Expert Comment

by:becraig
ID: 40206510
The command I gave you is for all mailboxes.

If you want for a single mailbox you would have to specify the user Identity.

For a specific server specify server.

Some good reading to help you better understand the get-mailbox command:
http://technet.microsoft.com/en-us/library/bb123685%28v=exchg.150%29.aspx
0
 
LVL 7

Expert Comment

by:Murali Reddy
ID: 40206955
Get-mailbox -Resultsize Unlimited | ***** yes, this is for all mailboxes in your organization.

if you want for a specific mailbox
get-mailbox -identity "Mailbox identity" |******
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This article explains how to install and use the NTBackup utility that comes with Windows Server.
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 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…

816 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now