?
Solved

Exchange 2010 - Powershell

Posted on 2013-10-23
6
Medium Priority
?
646 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
[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
  • 2
6 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39594585
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
ID: 39594631
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 750 total points
ID: 39594750
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 40

Expert Comment

by:Subsun
ID: 39595089
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
ID: 39595285
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
ID: 39595300
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

Introducing the WatchGuard 420 Access Point

WatchGuard's newest access point includes an 802.11ac Wave 2 chipset, providing the fastest speeds for VoIP, video and music streaming, and large data file transfers. Additionally, enjoy the benefits of strong security as the 3rd radio delivers dedicated WIPS protection!

Question has a verified solution.

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

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
One-stop solution for Exchange Administrators to address all MS Exchange Server issues, which is known by the name of Stellar Exchange Toolkit.
how to add IIS SMTP to handle application/Scanner relays into office 365.
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…
Suggested Courses

719 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