GD Bloggers

This is the blog site for Microsoft Global Delivery Communities focused in sharing the technical knowledge about devices, apps and cloud.
Follow Us On Twitter! Subscribe To Our Blog! Contact Us

Cleaning up specific user profile properties in SharePoint and avoid indexing them in Search

Cleaning up specific user profile properties in SharePoint and avoid indexing them in Search

  • Comments 1
  • Likes

After you setup SharePoint application and "My Site" then start to import user profile, you might need to cleanup information that was imported or prevent certain properties from being displayed anywhere in your application. This would happen in a scenario where the customer figures out that the information that was stored in and imported from active directory is not updated and you want to avoid displaying incorrect information across your application.

To make sure that such user information are not displayed across the site after being imported, you need to notice that this information is regularly updated and cached in multiple places in SharePoint. Basically...

  • Properties might be used for indexing in People Search
  • Properties for specific users might be cached in user information list

Avoid indexing specific properties

  • Go to user profile service: manage policies
  • Remove the connection from the title and job title fields
  • Make sure the property is optional
  • Make sure that the property is visible only to user manager as shown below
  • Make sure that property is not indexed for search
  • Settings highlighted below in the image

                


After you configure the properties…

  • After doing the settings and removing connection to active directory, the properties (title/job title) do not get repopulated to empty and retain the old values. Run the following script to ensure that values are cleaned-up properly.... 

#URL
$mySiteUrl = "http://sharepoint:77/"
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profiles = $profileManager.GetEnumerator()
foreach ($userProfile in $profiles) {
#Get user profile and change the value
          $userProfile["title"].Value = ""
          $userProfile["SPS-JobTitle"].Value = ""
          $userProfile.Commit()
}

  • After you run the script, check the user profiles from the service and make sure that fields are empty.
  • Perform full import to AD.
  • Check the user profiles again from the central administration and make sure that fields are empty.
  • Perform incremental search crawl to drop previously indexed properties

Removing cached user information from User information list

Some information will be cached in the user information list: “/_catalogs/users/simple.aspx", you need to make sure that information in this list does not hold reference to the user properties that you wish to clean up. Perform the following steps...

  • Run the following scriptto update the cached user profiles

$url = "http://SharePointSite/"
$site  = Get-SPSite $url
$list = $site.OpenWeb().SIteUserInfoList
Write-Host "Total Items:" +  $list.items.count
foreach( $item in $list.items)
{
     if( $item["Job Title"] )

     {
            write-host $item["Job Title"];
            $item["Job Title"] = "";
            write-host $item["Job Title"]; 
            $item.Update()
     }

}
$list.Update()

Comments
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment