Exchange Server | Murat Bilici

"Empower your knowledge"

Use the search-mailbox cmdlet to delete contacts in 2010

You can use the search-mailbox cmdlet to delete emails and content from mailboxes based on search strings, but what if you need to remove a certain type of content such as contacts?  Having come across a problem whereby an Android device synched 250,000 contacts to a users mailbox by accident (it went into some sort of loop!) there was no way to work with the mailbox using Outlook.

If you want to remove ALL contacts ONLY from a users mailbox you can run:

search-mailbox -identity USERNAME -searchquery kind:contacts -deletecontent

The kind:contacts is the key here.  You can specify other options such as calendar entries only, etc by looking at the list here –


To Restrict by File Type: Use Example
All file types everything kind:everything
Communications communications kind:communications
Contacts contacts kind:contacts
E-mail email kind:email
Instant Messenger conversations im kind:im
Meetings meetings kind:meetings
Tasks tasks kind:tasks
Notes notes kind:notes
Documents docs kind:docs
Text documents text kind:text
Spreadsheets spreadsheets kind:spreadsheets
Presentations presentations kind:presentations
Music music kind:music
Pictures pics kind:pics
Videos videos kind:videos
Folders folders kind:folders
Folder name foldername or in foldername:mydocs or in:mydocs
Favorites favorites kind:favorites
Programs programs kind:programs
Categories: Exchange 2010