SharePoint profile picture link missing “/”
-
29-09-2020 - |
Question
I have imported profile pictures from AD and is successfully synchronizing. The problem is that SharePoint is looking for the picture at the wrong location.
In the console i get this error:
GET http://sis-intranet/sites/mysiteUser%20Photos/Profile%20Pictures/sr_SThumb.jpg?t=63540923150 404 (OK)
This is because the link should be http://sis-intranet/sites/mysite/User%20Photos/
not http://sis-intranet/sites/mysiteUser%20Photos/
It's missing the "/" after mysite
Any idea how to fix this?
Solution
$site = get-spsite "http://sis-intranet"
#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://sis-intranet/sites/mysiteUser%20Photos/"
#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://sis-intranet/sites/mysite/User%20Photos/"
#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"
}
}
EDIT
yes its not permanant! you need to rebuild the user profile service so that it picks up the correct url. where are you picking up the image from? active directory? have you looked into the user profile settings in active directory? _admin/ServiceApplications.aspx goto user profile and under people click on manage user properties -> look for profile images and make sure its correct