I created this following script to import “My Links” items into the SharePoint User Profile. This might be useful for a various reason including extracting existing links from another User Profile database (see SQL query below).
The script uses a CSV file containing three columns – username, title and URL e.g.
DOMAIN\User2, Team, https://intranet/teamsite
If you need to extract data from an existing User Profile Database use the following query in SQL Management Studio. The schema is the same on SP2010 and SP2013.
select UP.NTname, UL.title, UL.url
from dbo.UserLinks UL, dbo.UserProfile_Full UP
where UL.RecordId = UP.RecordId
Save the output as a CSV file. You don’t need to include a header row.
Now to import the data into the User Profile Service, run the following script. You may need to run this as the Farm Account.
$filepath = “c:\mylinks.csv”
$context = Get-SPServiceContext($site)
$ProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$header = “Username”,”Title”,”URL”
$file = import-csv $filepath -delimiter “,” -header $header
foreach($line in $file)
$QuickLinkManager = $User.QuickLinks
$Title = $Line.Title
$URL = $Line.URL
That’s it. Now you have a script that can import thousands of items in seconds.
Note: Microsoft do not support directly updating SharePoint databases with a SQL query.