Update to the Wipe-ExchangeOnlineMailbox tool

Update to the Wipe-ExchangeOnlineMailbox tool

5/5 - (2 votes)

Who knew you’d need an update to a tool meant to delete things?

After working with a partner today and an out-of-control email application spamming user mailboxes, we decided an update was necessary.  Outlook became unusable with several hundred thousand messages in Deleted Items.  What to do, what to do, WHAT TO DO?

Fortunately, where there’s an EWS, there’s a way.

If you’re already familiar with the tool, you’ll know that I updated it a while ago to help you purge content in archives.  Today, I updated it to address items in two core folders: Deleted Items and Recoverable Items.

Imagine, for a moment, you have a gazillion messages in Deleted Items.  I don’t here, but just imagine. Astute viewers will also notice that I have items in Recoverable Items (surfaced in the new Outlook Web App view).

If I want to delete these items only, I can head off to my new-and-improved script, using the newfangled DeletedItemOptions parameter:

.\WipeExchangeOnlineMailbox.ps1 -Identity admin@undocumentedfeatures.onmicrosoft.com -Credential $cred -DeleteItemOptions DeletedItemsOnly

And … [drum roll]

ALL GONE.  I’ve sent them to the bit bucket in the sky with the HardDelete delete mode of the Empty() method:

$Folder.Empty([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete, $true)

Valid options for DeleteItemOptions are:

  • DeletedItemsOnly : Only rids yourself of Deleted Items
  • RecoverableItemsOnly : Kicks Recoverable Items to the curb (except Audits–that folder is protected for everything unless your name is SYSTEM)
  • Normal : The original.  When you absolutely, positively, must delete every damn thing–accept no substitutes.

For my next trick, we’re going to go see what we can do with Recoverable Items:

Yep, there’s something in there I had previously moved from Deleted Items.  Fortunately, we can get rid of these, too, with my updated script:

The result is both exciting and anticlimactic: EVEN MOAR GONE.

If you find yourself in need of deleting content, look no further than this lovely TechNet script.  I’m always deleting for you.

PowerShell Gallery: https://www.powershellgallery.com/packages/Wipe-ExchangeOnlineMailbox


Published by Aaron Guilmette

Helping companies conquer inferior technology since 1997. I spend my time developing and implementing technology solutions so people can spend less time with technology. Specialties: Active Directory and Exchange consulting and deployment, Virtualization, Disaster Recovery, Office 365, datacenter migration/consolidation, cheese.

Reader Comments

Leave a Reply

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