Powershell : How to identify (and delete) specific email messages from Office 365 1


I was looking for a way to identify messages in my Outlook Mailbox and easily delete them.

First connect to Office 365 with you (admin) credentials using the LiveCred command.

Set the Execution Policy and import the commandlets.

Using the next command creates an export of all emails from the specified user in the emailbox username and puts that export in the mailbox of user target mailbox and creates an folder called Searchlogs.

 

In that folder you find the logging of the files specified :

Results_powershell

 

Open the zip file containing the CSV export.

 

When you are ready to delete those files use the following command :

Now all the files from the specified user are deleted. You can also use the -subject:’subjectname” switch.

 


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

One thought on “Powershell : How to identify (and delete) specific email messages from Office 365

  • vworlddotnl

    Be sure to disconnect the remote PowerShell session when you’re finished. If you close the Windows PowerShell window without disconnecting the session, you could use up all the remote PowerShell sessions available to you, and you’ll need to wait for the sessions to expire. To disconnect the remote PowerShell session, run the following command : Remove-PSSession $Session