jdgregson / o365utils

Utilities to administer Office 365 and Exchange Online via PowerShell.
GNU General Public License v3.0
38 stars 8 forks source link

Add a -cleanup option #4

Closed jdgregson closed 5 years ago

jdgregson commented 6 years ago

When something goes wrong and the user exits Delete-Emails incorrectly, several compliance searches can be orphaned and left behind permanently. Delete-Emails names its compliance searches something similar to delete-emails-daa2450 so that they are easy to identify, but there is no easy way to remove them all at once.

We should add a -cleanup parameter to the script which will remove all searches starting with delete-emails-* and then exit.

One consideration though is that large organizations can be running Delete-Emails many times, and using the proposed -cleanup option could remove active deletion or confirmation searches for currently running instance of Delete-Emails. Maybe by default it will only remove searches which have completed more than five minutes ago?

jdgregson commented 5 years ago

This feature was added in commit a33c531. It will remove all compliance searches and compliance search actions that start with "delete-emails-" and are completed.