Solved

Deleting messages based on subject keywords

Posted on 2014-07-18
5
142 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

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

Find out what you should include to make the best professional email signature for your organization.
A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
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 discusses moving either the default database or any database to a new volume.

856 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