0

I have the follow problem: I try to import the profilepicture from ad into sharepoint. On the internet i find all kind of blogs that give me the same solution over and over.

  1. Create the mapping between Picture and "thumbnailPhoto"

  2. Do a full synchronisation.

  3. and do the following to create the thumbnail: Update-SPProfilePhotoStore -CreateThumbnailsForImportedPhotos 1 -MySiteHostLocation mysite

After doing these step i don't get the profile picture to work.

What did i do? I have a Active directory connection as type" active directory import "

one thing was a little strange and that the user profile sync services is not on. but i am sure that the synchronization works cause i tested it with other fields. the only field that doesn't seem to work is the profile picture.

Update:

What worked for me was change the active directory import to the user profile synchronization. Active directory import doesn't have the same functions as the user profile sychronization.

5
  • A short and simple answer - Active directory import does not work for the thumbnail photo. You need to use the other option. Commented Oct 12, 2015 at 10:32
  • what is the other option? Commented Oct 12, 2015 at 11:01
  • sharepoint.stackexchange.com/questions/118687/… Commented Oct 12, 2015 at 11:05
  • User profile sync instead of AD import. Commented Oct 12, 2015 at 11:05
  • i am going to change the sync method thank you all Commented Oct 14, 2015 at 7:47

1 Answer 1

1

You can sync the data using below mentioned power shell script.

-----------------------------------------------------------------------------   
Name:               Sync-SPUserInfoList.ps1
Description:        This script will update all of the properties in the User Information List with from the UPS 
Usage:              Make sure the UPS is connected to the Central Admin WebApp   
-------------------------------------------------------------------------    
Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0;  
    $ErrorActionPreference = "SilentlyContinue";  

    $PropertyMap=@("Title,PreferredName,Display Name",  
    "EMail,WorkEmail,EMail",  
    "MobilePhone,CellPhone,Mobile Phone",  
    "Notes,AboutMe,About Me",  
    "SipAddress,WorkEmail,Sip Address",  
    "Picture,PictureURL,Picture URL",  
    "Department,Department,Department",  
    "JobTitle,SPS-JobTitle,Job Title",  
    "FirstName,FirstName,First Name",  
    "LastName,LastName,Last Name",  
    "WorkPhone,WorkPhone,Work Phone",  
    "UserName,UserName,UserName",  
    "WebSite,WebSite,WebSite",  
    "SPSResponsibility,SPS-Responsibility,Ask About Me",  
    "Office,Office,Office");  

    $Context = Get-SPServiceContext $(Get-SPWebApplication -IncludeCentralAdministration | ? {$_.IsAdministrationWebApplication}).Url;  
    $ProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($Context);  

    if($ProfileManager){  
        foreach ($Site in $(Get-SPSite -Limit All | ? {!$_.Url.Contains("Office_Viewing_Service_Cache")})){  
            $RootWeb = $Site.RootWeb;  
            Write-Host $($Site.Url);  

            foreach ($User in $($RootWeb.SiteUsers)){  
                if ($ProfileManager.UserExists($($User.UserLogin))){  
                    $UPUser = $ProfileManager.GetUserProfile($($User.UserLogin));  
                    $UserList = $RootWeb.SiteUserInfoList;  

                    $Query = New-Object Microsoft.SharePoint.SPQuery;  
                    $Query.Query = "<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>$($User.UserLogin)</Value></Eq></Where>";  
                    $UserItem = $UserList.GetItems($Query)[0];  

                    ForEach ($Map in $PropertyMap){  
                        $PropName = $Map.Split(',')[0];  
                        $SiteProp = $UserItem[$PropName];  
                        $UPSProp = $UPUser[$($Map.Split(',')[1])].Value;  
                        $DisplayName = $Map.Split(',')[2];  

                        if($PropName -eq "Notes"){  
                            #Write-Host "$DisplayName Updated: $SiteProp - $($UPSProp[0].Replace("&nbsp;"," "))";  
                            $UserItem[$PropName] = $($UPSProp[0].Replace("&nbsp;"," "));  
                        }elseif($PropName -eq "Picture"){  
                            #Write-Host "$DisplayName Updated: $($SiteProp.Split(",")[0]) - $($UPSProp[0])";  
                            $UserItem[$PropName] = $UPSProp[0];  
                        }elseif($PropName -eq "SPSResponsibility"){  
                            #Write-Host "$DisplayName Updated: $SiteProp - $($UPSProp -join ', ')";  
                            $UserItem[$PropName] = $($UPSProp -join ', ');  
                        }else{  
                            #Write-Host "$DisplayName Updated: $SiteProp - $UPSProp";  
                            $UserItem[$PropName] = $UPSProp;  
                        }  
                    }  
                    #Write-Host "Saving: $($User.UserLogin)";  
                    $UserItem.SystemUpdate();  
                    #Write-Host "";  
                }  
            }  
            $RootWeb.Dispose();  
            #Write-Host "";  
        }   
    }else{  
        Write-Host -foreground red "Cant connect to the User Profile Service. Please make sure that the UPS is connected to the Central Administration Web Application. Also make sure that you have Administrator Rights to the User Profile Service";  
    } 

If you wish to set picture to AD user than below mentioned power shell script will help you for that.

$photo = [byte[]](Get-Content C:\Users\Administrator\Desktop\Users\user-icon.png -Encoding byte)
Set-ADUser oddvar -Replace @{thumbnailPhoto=$photo}

Note :- Please change the icon path in above script.

1
  • didn't use your script but atleast it can help people. I did change the active directory to user profile synchronization and the synchronization with the user profile sychronization. Commented Nov 11, 2015 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.