In this article we will discuss about my site deletion email message which user gets when their subordinate’s my sites is scheduled for deletion.

My site deletion task is taken care by ‘my site cleanup timer job’. it is responsible to delete my site which are scheduled to deletion. In this article we will discuss how the timer job works and what it does.

my site cleanup job

What is the my site cleanup timer job?

The My site cleanup timer job is responsible for user profiles and my site of those users. this includes following activities:

  1. Remove the user profiles which are queued for deletion
  2. If those users have my site then user’s manager added as secondary site owner. An email triggers to user’s manager that my site will be deleted in 14 days.
  3. After 11 days of first notification, again email triggers to user’s manager that my site will be deleted in 3 days.
  4. After a period of 14days it deletes the my site
    first thing we need to understand how the my site actually deleted

How is a user profile deleted in SharePoint?

There are couple of ways on how user’s profile deleted in SharePoint

  1. A user profile deleted when we delete it from the “Manage user profiles” section in Central Admin.
  2. When a user account which was included in previous profile import is no longer included in the next time.
    suppose you delete a user account in Active Directory and then incremental or full user profile synchronization. You would expect that this means the user profile deleted, and in fact this is picked up as a delete from Active Directory and processed in the FIM, where SharePoint picks up the fact the user profile is deleted and deletes it.

What happens when the “My site Cleanup Timer job “runs?

  1. When user leaves the organization or terminated then his account get deleted/disabled in Active directory
  2. Once the user’s account is deleted/disabled and SharePoint get to know about this, the my site deletion times job will be triggered in that user’s account
  3. It first remove the user profile from the SharePoint and once the profile removed the user will no longer access to the SharePoint sites and it’s quite obvious that user will not be able to access any resource as account is already disabled/deleted in Active Directory.
  4. Once the deletion part done then access delegation part of the user’s “my site” takes place. Now timer job looks for the user’s manager and will assign the manager’s account as the secondary owner for the user’s “My site”. This process will send and email to the user’s manager letting him know about his subordinate’s “My site” and will also have a link to the user’s “My site”.
  5. This would give complete access to the manager of user’s “my site” including My Documents folder.
  6. Suppose if the user doesn’t have a “manager” mentioned in his SharePoint profile then timer job will look for the Secondary owner of the user’s “My site”. if it finds a secondary contact it will then make secondary contact as the secondary owner of the “My site” and will send an email to the secondary owner.
  7. The email will be sent in three parts,
  • The first one will be a notification of the user’s “My site” with a link to the user’s “My site”
  • Second one will be the sent exactly 11 days after that and this will give a reminder to manager about his subordinate’s “My site”.
  • Finally the last one will be sent on the 14th day stating that user’s “My site” is deleted.

Note – it doesn’t mean timer job will run only when user’s account is deleted/disabled in Active Directory. Even if the user’s account is moved to different OU SharePoint will consider the fact that this account is no longer existing in the same OU as the profile synchronization connection is broken and will run the “My site” deletion timer job in the user’s account.

What happens when the user doesn’t have a manager?

Manager Profile property populatedSecondary contact configuredEmail sentSite queued for deletion
YesYesYes, to managerYes
YesNoYes, to managerYes
NoYesYes, to secondary contactYes

Is it possible to customize the timer job?

Yes it is possible to customize timer job. You can change the schedule and you can plan your own cleanup process.

Issue with the “My site “deletion email message in SharePoint Server 2013:

When user Profile is deleted from My site, and email is sent to the user’s manager. However, this email contains a link to the user’s root My Site which no loner exists. In addition you receive the following error message

This issue has been addressed in the September 8, 2015 update:

My site deletion email message in SharePoint Online:

When the OneDrive for Business account is scheduled for deletion, the default action to transfer ownership of the site to the manager of the user account that is being deleted. For this , the user profile Manager property must be set for the original owner of the OneDrive for Business site.

The access delegation setting is configured in the SharePoint admin center. This setting located in setup My site under user profile section. By default, Access Delegation is enabled. Sometime it is advised to configure secondary owner for site collection of user profile.

Set up my site on Admin Center

The profile and OneDrive cleanup process in SharePoint Online:

A work or school account is deleted from the Office 365 admin center or is removed through Active Directory synchronization.

  1. The account deletion is synchronized to SharePoint Online.
  2. The My site clean up timer job runs and marks user profile for deletion. the profile will be available in the database in a deleted state for 30 days. This coincides with the time that’s allocated to restore a deleted user account from the Azure Active Directory recycle bin.
  3. if the manager field populated for the deleted account, the manager will receive an email message that states that the site will be removed in 30days and that access to the site is granted to the manager.
  4. if the manager field doesn’t populate for the user account and secondary owner was configured in setup My site under the user profile section of the SharePoint admin center, the secondary owner contact will receive email message.
  5. Sevan days before the deletion date, second email will be sent to the manager or secondary owner as a reminder that OneDrive account in seven days.
  6. After seven days , the profile for the deleted account is deleted from the user profile service.
    The OneDrive for business site for deleted account is sent to the site collection recycle bin. The site is deleted from the recycle bin where it kept for 93 days. During this time, users will no longer be able to access any shared content in the OneDrive. To restore OneDrive you need to user PowerShell. For info please visit my blog Restore OneDrive Deleted site
Source Microsoft