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
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)
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'
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 https://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 https://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 = "https://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 "https://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 = "https://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 = "https://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
Anonymous
January 01, 2003
good jobAnonymous
January 01, 2003
Thanks a lot that was really helpful!Anonymous
January 01, 2003
Thanks a lot that was really helpful!Anonymous
March 06, 2013
Hi, Is workaround 3 a permanent fix? or the issue (missing /) will reappear after the next profile sync? Please clarify!Anonymous
April 25, 2013
did you ever find a permanent solutionf or this issue. We are up against the same issue as well. JustinAnonymous
April 20, 2014
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.Anonymous
October 16, 2014
Excellent, thank you!
:-)Anonymous
November 25, 2014
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%'Anonymous
January 28, 2015
Check your MySite host location and make sure you have included trailing / For instance: You have http://mysitehost and you should have http://mysitehost/Anonymous
May 21, 2015
Very good! That helped me a lot. Thanks!!