The case of the 340.000 contacts in a user mailbox

One of our users suddenly had this issue, this user had over 340.000 contacts most of them duplicates. As it turns out it was a syncing issue with his mobile phone. Deleting 340.000 contacts using Outlook is a painful task, so I figured out another way to do it. Here are the steps I took:

  • Disabled the synchronization
  • Restored the user’ contacts from a recent back-up into a PST file. We are using Commvault software which has this option. You can also export the existing contacts using PowerShell.
  • Deleted the contacts using PowerShell.
  • Moved the contacts from the PST back into the users mailbox.

Step 1, 2 and 4 are quite trivial, and I assume you know how to do that. The second task is a bit more complicated, and requires some special rights within your Exchange organization. The complete PowerShell command I used to delete only the contacts from the users mailbox:

Search-Mailbox -Identity USERNAME -SearchQuery "kind:contacts" -DeleteContent

At first I encountered that the Search-Mailbox cmdlet was unavailable:


As it turns out you need the “Discovery management” role within Exchange in order to use this command. Even though I am an Exchange organization administrator I added my account to this role using ECP. This fixed the missing Search-Mailbox cmdlet.

After fixing the Search-Mailbox cmdlet, I ran into another error. The parameter -DeleteContent was unavailable. In order to fix this error you need to add the “Mailbox Import Export” to the existing “Organization management” role. This finally allowed me to run this command, and here is the final result:


343311 contacts deleted, wow!

You can leave a response, or trackback from your own site.

One Response to “The case of the 340.000 contacts in a user mailbox”

  1. TRAN XUAN QUANG says:

    I used the command:
    Search-Mailbox -Identity NTVINH -SearchQuery “kind:contacts” -DeleteContent

    where:USERNAME is NTVINH

    To delete all contact of user mailbox, but it’s not success.
    the numbers of contact is to big 321199 items (contacts)

    Please help me to resolve the issue and email to me via address:



    RunspaceId : dd687fd5-090a-4949-8997-5a56d59fe327
    Date : 8/11/2012 12:33:20 PM
    Name : Contacts
    FolderPath : /Contacts
    FolderId : LgAAAACHbbLc6DfkToB/XG9LNzA+AQDlH2uf9p0fQb5912gm2XvAAAAAAfDXAAAD
    FolderType : Contacts
    ItemsInFolder : 321199
    DeletedItemsInFolder : 0
    FolderSize : 49.23 MB (51,626,354 bytes)
    ItemsInFolderAndSubfolders : 321199
    DeletedItemsInFolderAndSubfolders : 0
    FolderAndSubfolderSize : 49.23 MB (51,626,354 bytes)
    OldestItemReceivedDate :
    NewestItemReceivedDate :
    OldestDeletedItemReceivedDate :
    NewestDeletedItemReceivedDate :
    OldestItemLastModifiedDate :
    NewestItemLastModifiedDate :
    OldestDeletedItemLastModifiedDate :
    NewestDeletedItemLastModifiedDate :
    ManagedFolder :
    TopSubject :
    TopSubjectSize : 0 B (0 bytes)
    TopSubjectCount : 0
    TopSubjectClass :
    TopSubjectPath :
    TopSubjectReceivedTime :
    TopSubjectFrom :
    TopClientInfoForSubject :
    TopClientInfoCountForSubject : 0
    SearchFolders : {Lời nhắc, To-Do Search, AllItems}
    Identity : ntvinh\Contacts
    IsValid : True

Leave a Reply