• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3562
  • Last Modified:

Export Mail by Date Range to PST then Delete

I need help with a Powershell script.
I have Exchange Server 2007 sp3. with 30+ mailboxes.
I have installed the Exchange Tools on a Windows 7 32-bit workstation.

I would like to export select single mailboxes to pst files, including all folders and subfolders by date range for archival purposes, THEN Remove/Delete that same date range from their Mailbox.

What would the correct syntax be for this?

I'm successfully using the following to export by date range.  I just don't know how to make it delete upon completion.
Export-Mailbox -Identity <mailbox-alias> -StartDate "01/01/2014" -EndDate "03/31/2014" -PSTFolderPath c:\pstfile
0
Frank_Day
Asked:
Frank_Day
1 Solution
 
Joseph DalyCommented:
You would use the -deletecontent switch.  Obviously it goes without saying to test this on a test account before your actual users.

http://technet.microsoft.com/en-us/library/aa998579%28v=exchg.80%29.aspx

Export-Mailbox -Identity <mailbox-alias> -StartDate "01/01/2014" -EndDate "03/31/2014" -PSTFolderPath c:\pstfile  -deletecontent
0
 
Frank_DayAuthor Commented:
I've seen -deletecontent but I'm confused on how to use it.  It seems to always be in context with attachments, subject headings, etc.

If used as you have typed, would it only delete the date range previously stated?  Or does it need further input?

As you may have guessed, I know NOTHING about scripting.
0
 
Joseph DalyCommented:
Im on 2010 so I cant test for you but yes this should only delete the messages that match the criteria specified in the command.

That being said test, test, test before you put into action.
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
Adam BrownSr Solutions ArchitectCommented:
The -deletecontent switch might only work if you use the -targetmailbox and -targetfolder switches. At least, that seems to be how the description of the switch is worded. But definitely test it out :D
0
 
Frank_DayAuthor Commented:
UpDate, It Worked !

Export-Mailbox -Identity <mailbox-alias> -StartDate "01/01/2014" -EndDate "03/31/2014" -PSTFolderPath c:\pstfile  -deletecontent

This did in fact Export and then Delete all the folders and subfolders within the given date range ONLY.
0
 
Marshal HubsEmail ConsultantCommented:
You can export the items and then delete them by using following command:

Export-Mailbox -marshal@test.local -StartDate "01/01/2014" -EndDate "03/31/2014"” -PSTFolderPath C:\Backup\marshal.pst -deletecontent

Open in new window


Above command will export all items from all folders which are dated from 01/01/2014 to 03/31/2014 and will export them to a PST and delete them from the mailbox.

There are a few other export options:
 
  1. Specific keywords in the subject -SubjectKeywords
  2. Specific keywords in the content –ContentKeywords
  3. Specific folder -IncludeFolders ‘\Sent Items’
  4. Specific attachment name or extension-AttachmentFilenames

Alternatively, you can also use Stellar EDB to PST Converter to export selected items for a particular date range.  For free demo version, check this link: https://www.stellarinfo.com/email-repair/edb-pst-converter.php

15--1-.jpg
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now