We recently noticed that we had a user with 516,000 contacts in his mailbox. Many of them duplicated hundreds of times. We figured out this was an issue that other people had seen when switching from one mobile device to another. Mostly it seems from a BlackBerry to an Android. For some reason this has caused some users to experience a massive replication of contacts. I did not delve much into why as this had stopped already but we needed to clean up his current contacts. He had already tried to manually do it but this was not working.
It turned out the easiest way to clean up the contacts was to have him backup 1 copy of the correct contacts and then run the following PowerShell command.
Search-Mailbox -Identity "<user name>" -SearchQuery kind:contacts -DeleteContent -TargetMailbox "<logging mailbox>" -TargetFolder "SearchAndDeleteLog" -LogLevel Full
This command will search the <user name> mailbox for all contacts and delete them. This process will be logged into the folder SeachAndDeleteLog in the account you specify in <logging mailbox>
After this completed (about 3 hours) we had him replace his saved contacts.
Search-Mailbox replaces the old Export-Mailbox with deletecontent in Exchange 2010.
More information on Search-Mailbox can be found at http://technet.microsoft.com/en-us/library/dd298173.aspx
You can find information on advanced querying here http://msdn.microsoft.com/en-us/library/aa965711%28v=vs.85%29.aspx
This is exactly what I have been looking for but wonder if there is an easy way to back up a single instance of his contact before wiping it out?..thank you!
ReplyDeleteThe only way I found was to manually do it. I know not ideal if they have thousands of contacts. I am sure it could be done if we got really fancy with programming and storing contacts it see's then comparing it to whats been seen/stored but that was much farther than I wanted to go.
Deleteexport the users contacts to a csv then run this powershell script on it
DeletePS C:\> Import-Csv C:\contacts.csv | sort LastName,firstname,email -Unique | Export-Csv c:\test.csv
I'm lost on your example. Why are you doing "import-csv" and then doing the export-csv? I guess you're saying ONLY export the specific contacts contained in the CSV file??? Very confusing.
DeleteHe is importing the CSV file you manually created from the users contacts then cleaning it up and exporting a new file. he does this with the sort command between the 2 pipes. The -Unique removes all duplicates. His method is all external to Outlook and Exchange and you will need to import the contacts back into the users account through Outlook. The method I posted above does everything within Exchange but this is not an option for nonExchange admins.
DeleteThanks Craig for the comments. I want to be able to "find & delete" discreet, duplicate contacts within the so-called "Well-known Contacts folder" (or within any specific, named folder - not Public folders at all - just locally in each user's Outlook environment), via powershell (or other scripting). I have a powershell script that actually imports (via impersonation and EWS) contacts remotely via powershell, into users' Contacts folder but, the problem is, if you re-run it, it simply creates more and more duplicates. Not sure how the 'indexing' works for Contacts but, apparently, you can have 10 (or MORE) people all named "John Smith" and you won't get any errors - I guess it's basically a truly flat, non-indexed file. So, I need to search for contacts based on a contacts list, find contact that matches "John Smith," "Jane Jones," etc. and then either 'update' the specific contacts or delete/replace - the reason being that these users already have 'some contacts' besides the ones I imported to their folders. So far, most examples on modifying discreet contacts within a folder are sadly lacking. Thanks again - I'll keep working on it.
DeleteBoth methods above work, the one Dave posted might be easier for you. If you use his method keep in mind you need to purge all of the users contacts before you import the cleaned up list or yes you will get duplicates again.
DeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI used to the command below to delete all contacts of mailbox, but it is not success.
ReplyDeleteSearch-Mailbox -Identity ntvinh -SearchQuery "kind:Contacts" -deleteContent -targetMailbox "QUANGTX" -TargetFolder "NTVINH" -LogLevel Full
Please help me to resolve the issue and email to me via quangtx@vietinbank.vn
THanks and Regards
===============================================
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