Remove recent email imported into Outlook 2016

365techca
365techca used Ask the Experts™
on
Tech on my team imported former employees email into Outlook 2016 (client using Office 365) instead of Opening PST file is there any way to batch remove the contents of the PST file?

Either a search filter and pressing delete or an automated script through Office 365 powershell? Perhaps something that triggers based on massive data change,

Edit: We are also looking to remove contacts/calendar entries. Once the information is removed I will just attach the PST file to the managers Outlook Profile.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
timgreen7077Exchange Engineer
Distinguished Expert 2018

Commented:
No there is no way to batch remove those specific emails that was imported from that pst into the mailbox. unfortunately this will be a manual process.
Saif ShaikhServer engineer

Commented:
As TIM suggested,

There is no way to undo.

Simply blow out or delete anything before today in Outlook, so only today's email remain then restore her emails up to yesterday from backup.  You still need a PS script to check and delete empty folders.  Then add the ex employee's pst as an additional data file.

Here are some PS scripts you can use to delete empty folders: https://social.technet.microsoft.com/forums/scriptcenter/en-US/8210b3a0-9605-446c-8e84-b68e5ae01e38/powershell-checking-for-empty-folders-and-deleting
There could be possibility to delete those mails using following article.

https://docs.microsoft.com/en-us/office365/securitycompliance/search-for-and-delete-messages-in-your-organization

As per me you need to add query TO: whose mails needs to be deleted.

Please check and try it.
You can try using Search-Mailbox with -DeleteContent switch; however, you will have to specify a very accurate -SearchQuery for that. Unfortunately, it is not possible to base the query on the "import date", still - the method has the potential to reduce the time you spend on the manual cleanup.
If you have a pre-import backup copy for this user - that would be the easiest way to go.
Here are some articles which will help you use the Search-Mailbox cmdlet.
How to delete email from mailboxes on Exchange 2016 / 2013 / 2010 / Online
Search-Mailbox (Exchange 2013, 2016, Online): Attributes
Looks like I got it sorted, took a backup involved MS Office 365 support

 Search-Mailbox -identity "manager@domain.ca" -SearchQuery 'kind:meetings AND to:importeduser@domain.ca' -DeleteContent

And for the mail, using Outlooks Boolean logic did the trick:

to:importeduser@domain.ca NOT distribution_group NOT manager

Thanks for the help all.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial