Restoring Quick Links In MySite

Recently, I came across an issue where a user reported that he lost the Quick Links stored in his MySite. The user said that he had many links added in his MySite and all of a sudden, they vanished. Since he did not have any local copy of those links, he requested for help in getting them back as those were very important links related to his projects’ sites in SharePoint. The user also said that none of his colleagues lost their quick links. So, it was evident that the issue was not a major one as it impacted only single user, and whatever happened would have been accidental.

At first, I was wondering how it could happen if not done intentionally. However, later I realized that any application can run into weird issues and SharePoint is not an exception.

I did the following troubleshooting with no success in getting at what was wrong with that user’s quick links.

  1. Recreated user’s MySite.

  2. Restored the content database containing user’s MySite, using DPM [Data Protection Manager] and then, restored the MySite using PowerShell.

  3. Checked if there are any links stored in user’s profile using PowerShell [code below]. Well, it didn’t show any.
    1. $site = Get - SPSite https: //mysites.mydomain.com  
    2.     $serviceContext = Get - SPServiceContext $site  
    3. $upm = new - object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)  
    4. $User = $upm.GetUserProfile("domain\userName")  
    5. $User.QuickLinks.GetItems() | Select Title, URL | FT– auto   

After a long brainstorming session, finally I decided to opt for a different approach in order to get the links back. It was risky though but since there were some signs of assurance, I went ahead with this one.

Since all the details related to user profiles are stored in the “User Profile Database”, I wanted to restore the database from an earlier backup. Usually, we need the assistance of the person who handles the SQL part. However, in my case, I had access to the SQL instance. Upon that, we were having DPM [Data Protection Manager] which regularly takes backup of all our databases. This made my task easier than it sounded.

First, I found the name of the User Profile Database used by our User Profile Service Application. I followed the following procedure. 

 

  • Go to Central Administration >> Manage Service Applications
  • Select User Profile Service Application and click on the “Properties” button available in the ribbon area on top of the page.
  • Get the User Profile Database Name and Server details.

 


Next, I connected to DPM, retrieved the User Profile Database from earlier recovery point, and stored its .mdf and .ldf files into an SQL Server. I attached these files to SQL instance.

Navigated to “Databases” >> “UserProfileDB” >> Tables >> UserProfile_Full.

Executed the following query against the table. 

  1. USE[UPSProfileDB]  
  2. GO  
  3. SELECT[PartitionID], [RecordID], [UserID], [NTName], [PreferredName], [Email], [SID], [Manager], [SipAddress], [LastUpdate], [LastUserUpdate], [LastImported], [bDeleted], [DataSource], [MasterRecordID], [ProfileSubtypeID], [DSGuid], [PictureUrl]  
  4. FROM[dbo].[UserProfile_Full] WHERE NTName = 'domain\userName'  
  5. GO   

Noted down the RecordID.


Next I ran the below query against  the “UserLinks” table. RecordID is the value which I noted down in the previous step. 

  1. USE[UPSProfileDB]  
  2. GO  
  3. SELECT[PartitionID], [Id], [RecordId], [Title], [GroupType], [GroupTitle], [Url], [ContentClass], [PolicyId], [ItemSecurity]  
  4. FROM[dbo].[UserLinks] WHERE RecordId = 7627  
  5. GO   

My fingers were crossed while executing the query and that did the trick probably. I got the list of links which were missing in the user’s MySite.


Since I got the links and the user confirmed that those were the links, the final step was to add them back to the User’s profile in User Profile Service Application so that the user’s MySite could show the same.

I ran the below command to add the link for testing. 

  1. $site = Get - SPSite http: //mySiteHost.domain.com  
  2.     $serviceContext = Get - SPServiceContext $site  
  3. $upm = new - object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)  
  4. $user = $upm.GetUserProfile("domain\NTID")  
  5. $User.QuickLinks.Create("Test""https://www.google.co.in""General", $null"Private")   

This command added the link to the user’s quick links.


Though I could add all the links one by one, being a lover of PowerShell scripting, I prepared a script to do the same in one shot [script and input file is below].

The script required 3 inputs.

  1. Input file in CSV format containing links to be added.
  2. MySite Host URL
  3. User Account

Once I provided the inputs as required, the script did its job and made my life easier.


Bingo!!! All the links were back.


Hope this helps someone!!!

Happy SharePointing……..

Up Next
    Ebook Download
    View all
    Learn
    View all