Active Directory Picture Synchronization

1 minute read

When you have stored the pictures of employees in Active Directory you would like to have the option to synchronize these pictures to their SharePoint profile.

This article describes the steps you need to take to import them into the SharePoint profiles.


1. Change the mapping of the Picture profile field.

Navigate to the User Profile Service Application and got to “Manage User Properties". Find the picture property and select the edit menu item. Add a new Mapping to the “thumbnailPhoto” attribute and select “Ok” when you are done.


AD Mapping


AD Mapping After

2. Perform a Full Import

On the User Profile Service Application select “Start Profile Synchronization” to start a Full Synchronization.

3. Run the command Update-SPProfilePhotoStore

This command let will create the profile pictures in the “User Photo” library in the Mysite host site collection. Run this command with the following options:

Update-SPProfilePhotoStore -MySiteHostLocation [Your Mysite Host Location] -CreateThumbnailsForImportedPhotos 1


4. Check the profiles for their pictures.


One downside to this is that you need to rerun the Update-SPProfilePhotoStore when you have a new Employee for example.


When you would like to try this out on your environment you can use the following PowerShell script for importing a picture in Active Directory.

$username = "tpicture"
$picture = "C:\Pictures\msftplayground.png"

#get the active directory information
$dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$root = $dom.GetDirectoryEntry()
$search = [System.DirectoryServices.DirectorySearcher]$root
$search.Filter = "(&(objectclass=user)(objectcategory=person)(samAccountName=$username))"
$result = $search.FindOne()

#if the result not equal to null
if ($result -ne $null){
    $user = $result.GetDirectoryEntry()

    #get the byte array of the picture
    [byte[]]$jpg = Get-Content $picture -encoding byte
    #change the active directory property
    $user.put("thumbnailPhoto",  $jpg )

    Write-Host $user.displayname " updated" -ForegroundColor Green
} else {
    Write-Host $username " Does not exist" -ForegroundColor Red