Update to Wipe Exchange Online Mailbox script

4.9/5 - (7 votes)

Earlier today, I was asked to make an update to my script to wipe Exchange Online mailboxes to include Archive Mailboxes.  Fortunately, it ended up being much easier than I anticipated:

When I enumerated the mailbox originally, I used:

$Root = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, [Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Root)

In order to access the Archive folder, I just had to change the WellKnownFolderName from Root to ArchiveRoot, after examining the list available at https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.wellknownfoldername(v=exchg.80).aspx.

$Root = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, [Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::ArchiveRoot)

But, not being able to leave well enough alone, I wanted to provide some additional options, such as wiping only the mailbox, only the archive, or both, or being able to specify more than one user on the command line.  You can pick up the new and improved version at the TechNet Gallery: https://gallery.technet.microsoft.com/Wipe-Exchange-Online-331ab4f4 PowerShell Gallery: https://www.powershellgallery.com/packages/Wipe-ExchangeOnlineMailbox/

author avatar
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.