Skip to main content

SharePoint 2010– Profile Pictures not showing up Correctly

SharePoint 2010– Profile Pictures not showing up due to incorrect URL



Scenario
Profile Pictures inside User Profile Service Application for some users show Red X mark
image
Cause
This can happen due to 2 reasons
1) Profile Picture was deleted or went missing
2) Due to incorrect URL
Question - How to check the Picture URL associated to the user
Answer – We can check this by right clicking the Picture inside User Profile(Central Administration > Manage Service Application > User Profile Service Application > Manager User Profiles)
Search for the user profile and then click on Edit my profile
Now Right click on the Picture to click on properties(Picture URL is shown under the Address)
image
Alternate Way – We can run the following Select query against the Profile DB to get the Picture URL for a User
Select PictureURL from UserProfile_full with(nolock) where NTName = 'contoso\user1'
image
When we tried browsing the URL we realized that the URL is incorrect, It was pointing to http://MySiteHose/UserPhotosProfile Pictures/temp.jpg instead of http://MySiteHost/User Photos/Profile Pictures/temp.jpg (Difference of just a slash “/” )
Resolution
Workaround 1 We can update this manually by going to user profile properties inside user profile service application and linking it to the correct picture
Workaround 2 – Powershell Way(One User at a time)?
$site = get-spsite http://SiteCollection
#Give URL of a site collection whose web application is associated with this user profile service application $context=  [Microsoft.office.server.servercontext]::GetContext($site)
$userProfileManager = new-object Microsoft.office.server.userprofiles.userprofilemanager($context)
$profiles = $userProfileManager.GetEnumerator()
   foreach ($profile in $profiles)
    {
     if($profile["AccountName"].value -eq "contoso\user1")
        {
            
               $url = "http://MySiteHose/User PhotosProfile Pictures/temp.jpg"
               #Provide the correct URL for the picture                $profile["pictureurl"].value = $url
               $profile.commit()
       }
    }     
Workaround 3 – Powershell Way (Users in bulk)    
$site = get-spsite "http://SiteCollection"
#Give URL of a site collection whose web application is associated with this user profile service application $context=  [Microsoft.office.server.servercontext]::GetContext($site)
$userProfileManager = new-object Microsoft.office.server.userprofiles.userprofilemanager($context)
$profiles = $userProfileManager.GetEnumerator()
   foreach ($profile in $profiles)
    {
    $Matchurl = "http://mysitehost/User PhotosProfile Pictures"
    #Provide the incorrect URL for the picture
     if($profile["pictureurl"].value -match $matchurl)
        {
             
                Write-host $profile["AccountName"].value "contains incorrect url"
                $CurrentURL = $profile["Pictureurl"].value
                $CurrentURL = $CurrentURL.tostring()
                $GoodUrl = "http://mysitehost/User Photos/Profile Pictures"
                #Provide the correct URL for the picture
                $CorrectUrl = $CurrentURL.replace($matchurl,$goodurl)
                $profile["pictureurl"].value = $correcturl
                $profile.commit()
                Write-host $profile["AccountName"].value "PictureURL has been corrected"
       }
    }
Note – In my case difference was of a slash, it is quite possible that in your case difference is with the image name. For example User1 is pointing to xyz.jpg where as it should be pointing to abc.jpg
In such cases we will need to rework the $MatchURL attribute and associate the pictures accordingly.
Make sure you have proper backup in place before making any change

Comments

Popular posts from this blog

Migrate Secure Store Service Application from SharePoint 2013 to SharePoint 2016

Creation of Secure Store Service Application failed because of the following errors: The Timer Job Completed but failed on one or more machines in the farm.

HTTP 403 Forbidden SharePoint 2013