I was asked by a client to provide some clarity and guidance on understanding how User Profiles and Mysites are removed from a SharePoint farm.
Google provided much confusion on the subject, but these 2 posts stood out;
- Kirk Evans – Inside the SharePoint 2010 My Site Cleanup Timer Job
- Joel Oleson – SharePoint Profile Cleanup and the My Site Cleanup
However these 2 posts contradict each other, indeed Kirk’s post references Joel’s stating that it is wrong. I therefore set out to clarify how this worked myself, so I cracked open ILSpy and started looking at the timer job in question.
The My Site Cleanup Job timer job is found in the Microsoft.Office.Server.UserProfiles assembly found in the ISAPI folder in the 14 hive, and reading through the code, it seems that Kirks post describes the process of User Profile deletion and Mysite removal correctly.
I won’t rehash what Kirk has said, read his post for the full story, but I’ll summarise it here and hi-light an outcome missing from his post.
SharePoint User Profiles are marked for deletion during User Profile Synchronization, when a user account meets the Exclusion Filters (of the Synchronisation Connection) where previously it did not.
SharePoint sees this situation as an indication to delete a User Profile, and potentially the users My Site site-collection.
Typically an exclusion filter might exclude user accounts that are;
- Deleted from Active Directory
- Disabled in Active Directory
The User Profile Synchronisation Service does not remove User Profiles or Mysites, this function is performed by the My Site Cleanup Job timer job, which by default is scheduled to run every hour.
The timer job will immediately remove user profiles marked for deletion (by FIM Synchronization) and will also potentially remove a Mysite associated with a user profile according to the following matrix;
|Has Manager Property||Has My Site Host Secondary||Manager/Secondary Contact has Email Address||Email is Sent||My Site Scheduled for Deletion||User Profiles is Removed|
|Yes||No||Yes||Yes, to Manager||Yes||Yes|
|Yes||Yes||Yes||Yes, to Manager||Yes||Yes|
|No||Yes||Yes||Yes, to Secondary Contact||Yes||Yes|
My Site deletion is controlled and performed by the “My Site Cleanup Job” timer job, Site Use Confirmation and Deletion (in Central Administration – Application Management) plays no part in this.
A My Site will be deleted 14 days after the site was initially scheduled for deletion, irrespective of whether email notifications have been sent or not.
If a user profile has an assigned Manager, or a My Site host secondary contact exists, then;
- They will be assigned as a secondary site collection administrator of the My Site
- They will receive an initial notification email informing them of the pending My Site deletion in 14 days time (if the manager or contact has an email address)
After 11 days, the Manager or My Site host secondary contact will receive a reminder email notification informing them of the pending My Site deletion in 3 days time.
After the 14 days have elapsed, the “My Site Cleanup Job” timer job will irrevocably remove the My Site.
The text of the email notifications and the notification and deletion timescales are not configurable.
- Before editing User Profile Synchronisation Connections, disable the “My Site Cleanup Job” timer job and ensure it is not running
- The user assigned temporary ownership of a My Site scheduled for removal should either copy important content or perform a site collection backup of the My Site.
- To disable removal of My Sites, while maintaining removal of SharePoint user profiles;
- Ensure that the My Site host does not have a secondary contact configured (My Sites setup/configuration in User Profile Service Application)
- Before an account is deleted/disabled in Active Directory, the user accounts Manager property should be cleared
3 thoughts on “SharePoint: Demystifying User Profile Deletion & Mysite Removal”
“timer job will irrevocably remove the My Site” is not correct, by using restore-spdeletedsite you can restore the “deleted” My Site within some seconds
Hi, many thanks for explanation I was also confused by contradicting articles on this. To add more complexity can you please explain as well if the Set-SPOTenant -OrphanedPersonalSitesRetentionPeriod parameter plays any role in this?? Are the emails to Line Manager send out AFTER the retention period expires?? I hope yes…. just checkin…