Grabbing Your Pretty Mug from Active Directory

I do not normally create blog posts around topics which are covered on other blogs on the Internet however this topic seems to still draw a bit of confusion as well as I wanted to offer a very complete picture (pun totally intended) of how to move user pictures from Active Directory into SharePoint User Profiles.

Getting Started

For this walkthrough I am using a SharePoint 2010 Farm running the April 2011 CU and a single domain controller on Windows 2008 R2.

Domain: SPCOM
DNS Domain:
My Site Host: http://my

I have a number of demo users I have created within Active Directory and I have imported pictures/photos for each user via PowerShell. The PowerShell snip below takes a path to a jpg file ($fileName), reads the file into a byte array, and puts the data into the thumbnailPhoto attribute of a user.

$temp = get-content -encoding byte $fileName 
$photo =  [byte[]]$temp 

$newUser.put("thumbnailPhoto", $photo)


Once the photo has been set for the user we can use ADSI Edit to confirm as much:

Configure SharePoint

At this point we are ready to configure SharePoint 2010. From the User Profile administration pages select Manage User Properties and choose the edit the Picture property. Scroll to the bottom of this page and choose or ensure the Source Data Connection is the connection to your Active Directory. If you don’t have anything in this drop down list it means you have not configured User Profile Synchronization. I suggest you stop right here and jump on over to Spence’s blog post on the topic. For the attribute choose thunbnailPhoto and direction should be Import. At this point please do yourself a favor and hit the Add button. A common mistake is to skip over the add button and hit the OK button however you are going to be disappointed with the results because that effectively does nothing for you and makes no changes to the property mapping.

Before we move on lets confirm the mapping is in place.From the properties list we should see the picture property with a mapped attribute of thumbnailPhoto as in the image below.

Jumping back into the properties of the Picture attribute we should see the mapping here too. If we have these settings in place we are good to move on.

With the User Properties configured property its time to start a full profile sync. Its important this is a full sync and not an incremental. It’s a good bet the profile sync is going to take a fair amount of time.

Once the full profile sync is complete we need to run a bit of PowerShell which will migrate the user pictures from the User Profile store to a location where they can be accessed via a URL and used within SharePoint. This PowerShell was added to the product in the October 2010 CU and the command is documented here. The command is super simple to run and the PowerShell snip below shows you what this looks like for my environment.

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

### CreateThumbnailsForImportedPhotos added in Oct 2010 CU ####
Update-SPProfilePhotoStore -MySiteHostLocation http://my -CreateThumbnailsForImportedPhotos $true

There are a couple of things you need to be aware of before you attempt to run this command:

  1. The user running this command will need permissions to execute PowerShell against the User Profile Manager. To ensure this is the case open Central Admin, navigate to Manage Service Applications, highlight the User Profile Synchronization Service Service Application and choose Permissions. Note I did not mention Administrators but rather Permissions. From inside the Permissions dialog add the user which whom you will use to run the PowerShell script. If you don’t do this you will receive an error such as: Update-SPProfilePhotoStore : Object reference not set to an instance of an object and as they say in Texas, that dog won’t hunt.
  2. This command walks through your entire User Profile store pulling out each image for every user and creates a large, medium and small thumbnail and uploads those images into the User Photos picture library at the root Site Collection of your My Site Host. So for 30,000 users you will end up with about 90,000 images in this library. The PowerShell command will pause or block until this is complete so just plan for this to take a while. 

Once you have finished running the CreateThumbnailsForImportedPhotos command (or while waiting for it to complete), you can open the My Site Host, choose View All Site Content, and verify the number of items in the User Photos picture library.

That’s it, you are done; you have just successfully migrated pictures from Active Directory into the SharePoint User Profile store, and then finally into the My Site host for your farm.

9 thoughts on “Grabbing Your Pretty Mug from Active Directory

  1. So, the sync imports AD photos into the User Profile Store? And the PS brings those into /User Photos? Where exactly is the User Profile Store? Is that just a SQL DB? Are there certain permissions required there for this to work? I get no errors running PS after full sync, but no photos either…


  2. Great goods from you, man. I have understand your stuff previous to and you’re just too magnificent. I really like what you have acquired here, certainly like what you are stating and the way in which you say it. You make it entertaining and you still take care of to keep it wise. I can not wait to read far more from you. This is really a great site.
    <b><a href="">bridesmaid dresses</a></b> | <b><a href="">prom dress</a></b>


  3. Pretty good source, I would say, even excellent. There is hardly ever where you can find so many useful for beginners, information. Although I advanced user, but still met here are some interesting things.


  4. Hi,
    Article is great! I followed the steps and all has worked. What i have strugged to find on any site, is what is the recommended process for me to follow when the following conditions are met:
    – new users join the company therefore new pictures
    – existing users are vain and want a new photo uploaded

    Should i schedule a daily scheduled task to run the following:
    Update-SPProfilePhotoStore -MySiteHostLocation http://my
    and a monthly to run the following:
    Update-SPProfilePhotoStore -MySiteHostLocation http://my -CreateThumbnailsForImportedPhotos $true

    Guidance on this would be great,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s