none
Delete the messages from the archive mailbox of the user before a specific date RRS feed

  • Question

  • Hello everyone,

    I would like to know if there is a way to delete messages up to a specific date specifically for the Archive mailbox of a user.

    The idea is to export the mail of the user from before a specific date to a PST file, then subsequently delete the e-mails from the archive.

    I found the PowerShell command to do the export:

    New-MailboxExportRequest -Mailbox USER -IsArchive  -ContentFilter {(sent -lt "01/01/2016")  -or (Received -lt "01/01/2016")  } -FilePath “\\MYSERVER\c$\pst\USER-Archive.pst"

    Do any of you have any idea how to delete the email matching the same criteria after the user archive PST has been created?

    Thank you for your help

    Lucas

    Tuesday, May 14, 2019 4:09 PM

All replies

  • In general, if you want to be on the safe side, you should use some EWS-based script such as the one here: https://www.sunilchauhan.info/2015/09/Remove-Emails-from-specific-folder-between-specific-date-range.html

    Reason being, all the other methods (Search-Mailbox or retention policies) will apply to both the primary and archive mailboxes and might delete other matching messages as well.

    Tuesday, May 14, 2019 5:57 PM
  • Hi Lucas,

    As Vasil suggested, you can try using the EWS script. See the following blog article for more details:

    PowerShell: Search mailbox for items of a particular message class (ItemClass)

    Use the SearchArchive and DeleteItems parameters:

    -SearchArchive: If this switch is specified, then the archive mailbox for the account (not the main mailbox) will be searched
    -DeleteItems: If this switch is specified, any items found will be deleted (use with care!!)

    Regards,
    Steve Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Wednesday, May 15, 2019 9:42 AM
    Moderator
  • Hi,

    thank both you for your reply.

    I wonder if there is something more simple.

    Some of our user have more than 50 GB in their archive.

    One of my idea was to create one pst with the command line I showed before " from today until January 2009" and then associate that pst as the new archive mailbox of the user.

    I don't know if it's possible.

    Regards,

    Lucas Vorms

    Thursday, May 16, 2019 1:06 PM
  • Hi Lucas,

    >>One of my idea was to create one pst with the command line I showed before " from today until January 2009" and then associate that pst as the new archive mailbox of the user.

    I'm afraid it's not gonna work. There is no global setting or GPO to force an automatic archiving to a local .pst file. Archiving at end user side is a per-user feature, administrators have no much control over it.

    Regards,
    Steve Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Friday, May 17, 2019 5:41 AM
    Moderator
  • Just wanted to say hi and check if there is anything that we can do for you on this problem. If so, please do not hesitate to let us know and we will be happy to help.

    Best regards,
    Steve Fan 


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Tuesday, May 21, 2019 9:26 AM
    Moderator
  • Hi Lucas,

    Any further query here?

    Regards,
    Steve Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, May 27, 2019 2:38 AM
    Moderator
  • Sorry for the delay.

    I had another idea I would like to know if it's duable.

    Step1) Export the archive from User x to a PST

    Step2) From the PST run a powershell to extract the PST from "Today - 10 years".

    Step3) From the "PST today - 10 years" import it to Exch archive of the user.

    Do you think it's possible ?

    Thank for your help.

    Lucas

    Friday, July 12, 2019 11:24 AM