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/User PhotosProfile 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 2Powershell 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 (10)

  1. Herman Brood says:

    Very good! That helped me a lot. Thanks!!

  2. LW says:

    Check your MySite host location and make sure you have included trailing / For instance: You have http://mysitehost and you should have http://mysitehost/

  3. Phil Lunsford says:

    What worked for me was a simple SQL Script.
    UPDATE UserProfile_Full
    –Set the # of characters to the length of your old URL. Max length was set to 100, your results may vary.
    SET PictureUrl = substring(pictureURL,19,100)
    where
    –Set your old domain in here before the %
    PictureURL LIKE ‘http://olddomain:80%’

  4. Bjørn Roalkvam says:

    Excellent, thank you!
    🙂

  5. xia says:

    You can delete User Profile Service,and then recreate the service! What’s most important, When sync picture,the MySiteHost Url can not missing “/”, and the script run to show picture can not missing “/” too.

  6. justin howell says:

    did you ever find a permanent solutionf or this issue.  We are up against the same issue as well.

    Justin

  7. spadmin1 says:

    Hi,

    Is workaround 3 a permanent fix? or the issue (missing /) will reappear after the next profile sync?

    Please clarify!

  8. Parths2310 says:

    Thanks a lot that was really helpful!

  9. Parths2310 says:

    Thanks a lot that was really helpful!

Skip to main content