Wipe Exchange Online Mailbox Content

Periodically, you may find it necessary to remove all content in an Exchange Online mailbox.  Short of removing a license (and waiting for the soft deleted mailbox to expire), the only other option has been to log into OWA and delete everything or connect use Outlook to delete.

5 Star
3,456 times
Add to favorites
Office 365
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question

  • Error on Run, Need Help!
    1 Posts | Last post January 04, 2020
    • Hello!
      Love the script. It's working... some of the time. I'm attempting to delete a full 100GB mailbox, and so far, it has cleared out 40GB. Had to re-run it multiple times. But now I'm struggling to continue. I keep receiving the following errors every run through:
      Exception calling "Bind" with "2" argument(s): "The Url property on the ExchangeService object must be set."
      At C:\Users\XXXX\Downloads\WipeExchangeOnlineMailbox.ps1:209 char:6
      + ...             $Root = [Microsoft.Exchange.WebServices.Data.Folder]::Bin ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : ServiceLocalException
      You cannot call a method on a null-valued expression.
      At C:\Users\XXXX\Downloads\WipeExchangeOnlineMailbox.ps1:212 char:6
      +                     $FolderList = $Root.FindFolders($FolderView)
      +                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
      And then sometimes during a semi-successful run, I'll see this a whole bunch of times:
      Deletion failed with error 'Move/Copy messages failed.' for the following item:
      Any ideas how to get this working again?
      Thanks again - great script so far!
  • Calendar items and Contacts
    1 Posts | Last post August 30, 2019
    • I got it to work, however it also wiped all Calendar items and Contacts. Is there cmdlet we can add to exclude them?
  • Can't get it to work
    2 Posts | Last post August 02, 2019
    • Hi Aaron, 
      Thank you for this script. I am having trouble though. It runs though but I am getting errors like this:
      Deletion failed with error 'Move/Copy messages failed.' for the following item:
       Howard Matlin,"Calendar","airplane ge finance",True,5/12/2003 7:03:10 PM,6/19/2004 10:05:07 PM,Howard Matlin,/O=KELSO & 
      I am not at all familiar with PS. 
      Thank you, 
    • My guess is that the mailbox has litigation hold or a retention policy applied to it and it has exceeded the RecoverableItems quota.  Use my script http://aka.ms/userholdpolicies to check and see if the user has hold policies applied.
  • Can't get it to work
    1 Posts | Last post July 18, 2019
    • Error at the end:
      CategoryInfo          : ReadError: (0:Int32) [Search-Mailbox], SearchMailboxException
          + FullyQualifiedErrorId : [Server=DM5PR06MB3305,RequestId=6a508646-da17-403e-acb0-f077c7a10ad4,TimeStamp=7/17/2019 3:54:37 PM] [FailureCategory=Cmdlet-SearchMailbox 
         Exception] 959ED12B,Microsoft.Exchange.Management.Tasks.SearchMailbox
          + PSComputerName        : ps.outlook.com
  • Related to Migration impact
    2 Posts | Last post April 02, 2019
    • Hello, 
      Great script. Just a couple of items to ask, mention. 
      I am using in a 365 tenant that is a WIP. So we did not change any DNS records yet. I was able to address the auto discover dependency by adding an entry in Host file. 
      That appears to be the only requirement? (The others outlined in the associated posts were addressed by the script as advertised)
      I have one user whose source mailbox was larger than the 365 mailbox. I am using your tool to clear the 50 GB that migrated. The initial phases appear to be running fine. It is at the "Running the Search-Mailbox to finish up" phase (and has been for an hour). The progress bar is at "Searching...a search for the sourcemailboxes is in progress" and the bar has about a 20% progress and has not really moved. I am curious if the status bar of "searching...means it is looking for it, or if it processing and just taking a long time" 
      This mailbox as mentioned is in a migration (using third party tool). I wanted to empty the mailbox and restart completely. Is there any suggestions or should I just be patient. 
    • Patient. Unless I screwed something up by killing the job and restarting, I confirmed it is deleting the mail. Ignore question - 
  • Add User in bulk
    2 Posts | Last post March 12, 2019
    • Aaron,
      Thank you so much for this terrible script, i have a suggestion :
      Is it possible to add the feature that we could inport user via a CSV file ?
      Also could be amazing if there is a way to parallelize the tasks...
      But again, thank a lot for this script!!!
    • You can right now.  The -Identity parameter is an array, so you can put whatever you want in there.
      $identity = @("user1@domain.com","user2@domain.com")
      $identity = gc users.csv
      .\Wipe-EXOMailbox.ps1 -Identity $identity
  • Multiple mailbox wipe
    3 Posts | Last post October 19, 2017
    • Aaron, my Google search for a mailbox wipe script landed me here and I like the script you have published. I need to wipe multiple mailboxes and was wondering if there is a way to use this script in connection with Get-Mailbox | << cmdlet or some other pipe.
      Any suggestion/guidance you could provide will be extremely helpful.
      Thanks in advance.
    • You could run the mailboxes through it in a FOREACH loop for the time being.  This is a good functionality to add, so I'll spend some time working on it.
    • I've updated the script so you can do more than one identity at a time now.