Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Remove Deleted Items within Date Range via Exchange Management Shell

Posted on 2015-01-12
3
Medium Priority
?
566 Views
Last Modified: 2015-01-30
We are looking for an Exchange management shell command that will specify a user's mailbox and delete messages from their deleted items folder within a specified date range.

Any assistance would be appreciated.,
0
Comment
Question by:GR JN
[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
  • 2
3 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40544474
You can try the following powershell script to accomplish this...

This command below will do one individual user.
$Date = get-date
New-MailboxExportRequest -ContentFilter {(Received -lt $date.adddays(-100)) -and (Received -gt $date.adddays(-150) )} -Mailbox <mailboxName> -IncludeFolders "#DeletedItems#" -FilePath "\\servername\PSTFILES\name.pst"

Open in new window


If you want to do this for multiple users at once use the below command...
$Users = get-content "c:\users.txt"
$Date = get-date
foreach ($user in $Users) {
New-MailboxExportRequest -ContentFilter {(Received -lt $date.adddays(-100)) -and (Received -gt $date.adddays(-150) )} -Mailbox $User -IncludeFolders "#DeletedItems#" -FilePath "\\servername\PSTFILES\$User.pst"
}

Open in new window


Will.
0
 

Author Comment

by:GR JN
ID: 40544487
Thanks is there any way to do this from the exchange management shell directly without the need for .pst files?

If possible we would like to use something like the below but specify the deleted items folder and a date range:

Search-Mailbox -Identity "April Stewart" -SearchQuery "Subject:'Your bank statement'" -DeleteContent
0
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 1500 total points
ID: 40544798
When you are using Search-Mailbox and you want to deleted content you still need to provide a -Targetmailbox where the items can be copied to before you actually remove them from the mailbox.

Unfortunately you cannot use Search-mailbox cmdlet to accomplish subfolder deletions. You have to search the entire folder using the Search-Mailbox cmdlet.

See the link below for additional details
Cannot Search/Delete sub folder items using Search-Mailbox

Will.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
how to add IIS SMTP to handle application/Scanner relays into office 365.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

610 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