SharePoint 2010– Profile Pictures not showing up Correctly
- Get link
- X
- Other Apps
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 userSelect PictureURL from UserProfile_full with(nolock) where NTName = 'contoso\user1'
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
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$site = get-spsite "http://SiteCollection"
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)
#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
- Get link
- X
- Other Apps
Comments
Post a Comment