You have SharePoint 2010 or 2013 environment. You have also deployed My Sites and your users have been consuming the My Site Feature.
You had an old Users OU in your AD and now you decided to create a new OU for whatever reason. Then gradually you have been moving the users from old OU to the new OU.
While this moving users has been occurring for period of time, now few end users are receiving a warning email message that one of their reporting employee my site will be deleted.
This issue is around the below described specific scenario and the suggested resolution could be reviewed in your specific scenario based.
Let's say you have following below OUs for in your AD.
- OldUsers is the old OU
- New Users is the new OU
In the last one month your IT has been gradually moving users from OldUsers to New Users OU. In the SharePoint, the User Profile Synchronization is pointed only to the OldUsers OU. As the users were moved to the new OU New Users, following is been happening:
- The moved User Profile was deleted from SharePoint.
- If that user had a mysite and if the user had an assigned Manager in AD,
- Then the MySite secondary administrator was changed to the Manager
- The My Site was queued for Deletion in 14 Days.
- An email was sent to the Manager (This is first warning)
- After 12 days a second email was sent with notification that after 3 days the site will be deleted.
- If that user had a mysite and if the user had no Manager in AD,
- No email sent to any body
- No change in user administrator
- The site is queued for deletion in 14 days
The entire process is managed by a timer job called “MySite Cleanup job”. This timer job runs every day from 1AM-6AM (Default setting).
First and foremost disabled this timer job “MySite Cleanup job” to avoid any accidental My Site Deletion. The resolution is to gracefully recover from this issue and not directly edit the database table content which is not supported by Microsoft. So proceed with your own caution.
You will first need to determine the current state of User Profiles in the SharePoint Profile Database. Run the following simple Select query against your SharePoint Profile database
(For privacy reasons, the names and emails have been removed from the below screenshot)
- For each user, against the Created Date, calculate the 14 days date.
- In the SharePoint farm, under UPS revise the Connection to ensure to include the New User and OldUsers are also included
- Run full profile synchronization
- Ensure that now you can find all the users (or whatever the latest number from the above SQL query run) under the User Profiles
- Under the Monitoring, ensure the MySite Cleanup job is now active and is scheduled to run daily (Default)
- Ensure that the daily database backups are done
- Next step is to watch out for each of the marked user site collections to be deleted (The Site Collection does not get permanently deleted, with SP 2010 SP1 changes, the site collection now stays in the Site Collection Recycle bin at the Farm level) by the MySite Cleanup job, on the dates that you calculated by adding the 14 days.
- After a site is deleted by the MySite Cleanup job, next day, re-run the SQL Query to ensure that the user name is not listed in the SQL Query.
- Now run the following PowerShell command to check and restore the deleted site collection from the internal site collection recycle bin.
- On any server in the farm, run the Powershell, and run Get-SPDeletedSite, example below, Jane Smith site was deleted.
- Now run the Restore-SPDeletedSite as below"
- At this stage the user site is back as is and there is no entry for this site in the database table MySiteDeletionStatus
- If a manager was assigned as secondary site contact, then from the Central Administration, remove the manager as the Secondary Site Contact.
- This should get the User Site Collection re-instated as is.