PS cmd to delete emails on onprem Exchange mailbox, within specific date range

Patr_UK 120 Reputation points
2023-11-09T10:58:50.77+00:00

Hi

Looking for powershell cmds that could do the following:

  1. Search a mailbox for all emails within all folders, for a specific date range and then export to a csv
  2. Delete all the emails within all folders, within the same specific date range

Want to do this for an individual mailbox, that I will initially export from on-prem Exchange to a pst file on the network, using the New-MailboxExportRequest

Thank you

Exchange | Exchange Server | Management
Windows for business | Windows Server | User experience | PowerShell
{count} votes

Accepted answer
  1. Vasil Michev 119.8K Reputation points MVP Volunteer Moderator
    2023-11-09T17:09:45.4333333+00:00

    Have you looked at the Search-Mailbox cmdlet? https://learn.microsoft.com/en-us/powershell/module/exchange/search-mailbox?view=exchange-ps

    Do note that you cannot target specific folders with it, if that's a requirement, you will have to use an EWS-based script.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.