Solved

Exchange 2010 - Powershell

Posted on 2013-10-23
6
583 Views
Last Modified: 2013-10-23
Hi,

I try to delete from some of my users mailbox mails that are older then the 01/01/2000. I'm using:
Search-Mailbox -Identity "USER" -SearchQuery "Received:< 01/01/2010" -DeleteContent -force

It's working, the problem it delete all contacts that added before 01/01/2010 as well.
How can I still delete the mails older than 01/01/2010 but exclude the contacts folder from been deleted?

How to change the SearchQuery.
0
Comment
Question by:ym1
  • 4
  • 2
6 Comments
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
I don’t think Search-Mailbox will allow you to exclude or only include specific folders.. You can specify the the kind of items to search. So if you specify email, then it will search only for email items..

Try..
Search-Mailbox -Identity "USER" -SearchQuery "'kind:email' AND 'Received:< 01/01/2010'" -DeleteContent -force

Open in new window

0
 

Author Comment

by:ym1
Comment Utility
Subsun thanks it's doing part of the job as not delete the contacts but it not clear tasks and calendar.
0
 
LVL 40

Accepted Solution

by:
Subsun earned 250 total points
Comment Utility
You can add multipple conditions like

"'kind:email' OR 'kind:meetings' OR 'kind:tasks' AND 'Received:< 01/01/2010'"

Open in new window


Ref : http://msdn.microsoft.com/en-us/library/aa965711(v=vs.85).aspx
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 40

Expert Comment

by:Subsun
Comment Utility
Just wondering about the reason for B grade!

Please see the EE guidelines on grading..
http://support.experts-exchange.com/customer/portal/articles/481419
0
 

Author Comment

by:ym1
Comment Utility
just small point the syntax was not accepted, need to be:
Search-Mailbox -Identity "USER" -SearchQuery "(kind:email) AND (Received:< 01/01/2010)" -DeleteContent -force
0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
May be, I didn't tried... I cannot connect to my lab now..  If the quotes were not working you can try without quotes.. it should work as well..
Search-Mailbox -Identity "USER" -SearchQuery "kind:email AND Received:< 01/01/2010" 

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
This video discusses moving either the default database or any database to a new volume.

762 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

15 Experts available now in Live!

Get 1:1 Help Now