4

I would like to do as I used to be able to do with Exmerge with older versions of Exchange.

Basically, I need to be able to find messages that are older than a certain date, export those messages to a PST file and then delete them from the mailbox.

Is there a way to do this using the Exchange Powershell?

Any help appreciated

Thanks

fdf33
  • 177
  • 1
  • 4
  • 14

2 Answers2

6

As of Exchange 2007, you've been able to do this via powershell commands, e.g. Export-Mailbox and as of 2010 that's been your only (built in, at least) option..

Microsoft changed the powershell commands for Exchange 2010 SP1, and you should now use New-MailboxExportRequest to export data from a mailbox to a .pst file. I've given an example below.

Rather than attempt to summarise the arguments for the command, I'll simply point you at the Microsoft documentation for any further detail (this is also where I got the example below from).

New-MailboxExportRequest -Mailbox Tony -ContentFilter {(body -like "*company*") -and (body -like "*profit*") -and (Received -lt "01/01/2010")} -FilePath "\\SERVER\PSTFileShare\Tony_CompanyProfits.pst"
Rob Moir
  • 31,664
  • 6
  • 58
  • 86
  • Thanks. Is there a switch to delete the mail from the mailbox once it has been exported? – fdf33 Dec 08 '11 at 00:09
0

I want to point out some important points before running New-MailboxExportRequest Command:

1. You must have assign Mailbox ImportExportrole for exporting mailboxes to PST.

To assign it: New-ManagementRoleAssignment -RoleMailbox Import Export" -User

New-MailboxExportRequest -Mailbox -FilePath .pst {(Received -le 12/31/2019 23:59:59)} -Name

All mailbox items older than 12/31/2019 will be exported in .pst and that PST fill will be named .

Now you can use Search-Mailbox: this article is written by me.

Search-Mailbox -identity -SearchQuery 'Received<=2019-12-31 AND kind:email' -DeleteContent

ALL Set!!

Reference: https://community.spiceworks.com/how_to/102705-archiving-exchange-2013-mailboxes-to-pst-via-powershell

  • 3
    You appear to be the author of the article that you linked to. You need to disclose affiliation of this nature, otherwise this is considered to be spam. – cigien Dec 21 '20 at 11:30
  • How can I do it? – Eric Simson Dec 21 '20 at 11:35
  • When linking to your own site or content (or content that you are affiliated with), you [must disclose your affiliation _in the answer_](/help/promotion) in order for it not to be considered spam. Having the same text in your username as the URL or mentioning it in your profile is not considered sufficient disclosure under Stack Exchange policy. – Sabito 錆兎 stands with Ukraine Dec 21 '20 at 11:41
  • Just make it clear in the answer itself that you wrote the linked article. – cigien Dec 21 '20 at 11:43
  • I have added as you have suggested. – Eric Simson Dec 21 '20 at 11:51