How to put and retrive Active Directory Photo Attribute (thumbnailPhoto)

On Active Directory there is a thumbnailPhoto attribute where you can store user picture (the recommended thumbnail photo size in pixels is 96×96 pixels and should be under 10k in size).

First load ActiveDirectory module on powershell.

Import-Module ActiveDirectory

This first powershell script upload a picture (remember to change [Picture Path] with the path to your picture and [Username] with the AD username that you want to change thumbnailPhoto attribute

$photo = [byte[]](Get-Content [Picture Path] -Encoding byte)
Set-ADUser [Username] -Replace @{thumbnailPhoto=$photo}

And the second powershell script download user picture from AD

$user = Get-ADUser [Username] -Properties thumbnailphoto
$user.thumbnailphoto | Set-Content [Picture Path] -Encoding byte

UPDATE: Check this http://blogs.technet.com/b/exchange/archive/2010/03/10/3409495.aspx

4 thoughts on “How to put and retrive Active Directory Photo Attribute (thumbnailPhoto)

  1. Pasi Heino says:

    AD supports 100K pic, but exchange 10K pic. What happens, if pic is bigger than 10K? Is pic unavailable in Exchange/Outlook GAL?

    • LS says:

      As I now is the Exchange tool that limit you to using images less than 10 KB. If you upload an image bigger that this with different tool, is correctly displayed on Outlook or Lync. Anyway I think is important to keep the size as small as possible for minimize replication traffic.

Leave a comment