SharePoint 2013: How to Add Promoted Sites Programmatically

We encountered another problem some days ago where we wanted to add promoted sites to our User Profile Service application -> My Site Settings -> Manage Promoted Sites using PowerShell.

Before proceeding, we should understand what promoted sites are.

For promoting some of the sites to all or a specific user group, we can use Promoted sites.

The following procedure shows how to add promoted sites to Central Administration manually.

  1. Go to "User Profile Service application" –> "My Site Settings" –> "Manage Promoted Sites" under Central Administration.

  2. Now select "New Link" and fill in the required details for the Promoted Site as shown in the following screenshot.

  3. Save the Promoted link and go to "Sites" navigation added on Top-Right in the SharePoint page. You will be able to see the newly added promoted site as shown in the following screenshot.

  4. You can also add the promoted site using the "Manage" link available, as shown in the following image.

Let's see how to add a Promoted Sites link using server-side C# code.

  1. SPSite siteColl = new SPSite("");  
  2. using(SPSite ElevatedsiteColl = new SPSite(siteColl.ID))   
  3. {  
  4.     SPUser newUser = ElevatedsiteColl.RootWeb.EnsureUser(@  
  5.     "mydomain\user");  
  6.     SPServiceContext serviceContext = SPServiceContext.GetContext(ElevatedsiteColl);  
  7.     PromotedSitesViewWorker.AddSiteLink("""test1""test desc1", string.Empty);  
  8. }  

You need to add references and the following using statements.

  1. using System.Reflection;  
  2. using Microsoft.SharePoint.Portal;  
  3. using Microsoft.SharePoint.Publishing;  
  4. using Microsoft.SharePoint.Portal.UserProfiles;  
The following PowerShell Snippet will add promoted sites.
  1. Add - PSSnapin "Microsoft.SharePoint.PowerShell" - ErrorAction SilentlyContinue;  
  2. $site = Get - SPSite "";  
  3. $currentUser = [Environment]::UserDomainName + "\" + [Environment]::UserName;  
  4. $serviceContext=Get-SPServiceContext $site  
  5. $spuser=Get-SPUser -Web $site.RootWeb.Url -Identity $currentUser  
  6. $imgUrl="  
  7. ";  
  8. [System.Reflection.Assembly]::Load("  
  9. Microsoft.SharePoint.Portal, Version =, Culture = neutral, PublicKeyToken = 71e9bce111e9429c ");  
  10. [Microsoft.SharePoint.Portal.UserProfiles.PromotedSitesViewWorker]::AddSiteLink($serviceContext,$spuser,"  
  11. http: //","test12","test 12 decription", $imgUrl);