How To: Use AD PowerShell to Manage Outlook 2010 User Photos with Previous Versions of Exchange

by Mike Pfeiffer on June 9, 2010

You've probably heard about the new Exchange 2010 feature that allows you to import user photos into Active Directory so they can be viewed using Outlook 2010. To set this up, you use the Import-RecipientDataProperty cmdlet to store an image in an Active Directory user accounts thumbnailPhoto attribute. You can read more about it in this post on the Exchange Team blog.

So, what if I have Outlook 2010, but have not yet upgraded to Exchange 2010? I've gotten this question a few times lately. The fact is, the thumbnail photo attribute has been part of Active Directory since Windows 2000. So, even though you may not be running Exchange 2010, you can still import photos into Active Directory using PowerShell and view them in Outlook 2010.

In this post, I am going to demonstrate this using AD PowerShell. If you do not have this setup, you can read about it in my previous post located here. Alternatively, you should be able to accomplish the same thing using Quest AD cmdlets or ADSI.

Importing Photos with AD PowerShell

The following example uses AD PowerShell to import a photo named rhouston.jpg for a user named rhouston:

$photo = [byte[]](Get-Content C:\rhouston.jpg -Encoding byte)
Set-ADUser rhouston -Replace @{thumbnailPhoto=$photo}

After you've uploaded a photo for a user, you can view the image in Outlook 2010 when browsing the global address list, or in an email message, as shown below:

Exporting Photos with AD PowerShell

To export a photo that has been set for a user, you can use the following syntax. This would export the photo for a user named rhouston to a file named rhouston.jpg:

$user = Get-ADUser rhouston -Properties thumbnailphoto
$user.thumbnailphoto | Set-Content c:\rhouston.jpg -Encoding byte

I recently set this up in a small test environment running Exchange 2003 with Outlook 2010 clients and it works fine. Keep in mind, the recommended thumbnail photo size in pixels is 96x96 pixels and should be under 10k in size.

Related Posts

{ 4 trackbacks }

Active Directory で顔写真 « ブチザッキ
July 1, 2010 at 6:14 am
Bookmarks for June 28th through July 2nd | The Wahoffs.com
July 2, 2010 at 12:56 pm
User Photo’s Stored In Active Directory Can Not Be Displayed | James Brennan's Blog
June 2, 2011 at 8:26 am
Freeware – CodeTwo Active Directory Photos « Information Store
August 18, 2011 at 2:09 pm

{ 15 comments… read them below or add one }

BPuhl June 10, 2010 at 1:19 am

Sharepoint 2010 will do this automagically for you as well. You can have it publish your http://my site photo to AD, where it can be consumed by Outlook, OCS, etc… Yup – an actual end-to-end story… crazy huh?

Reply

Mike Pfeiffer June 10, 2010 at 4:52 am

Thanks, I hadn’t heard about that…that is really cool.

Reply

Peter Holpar August 9, 2010 at 5:10 pm

Hi BPhul,

Would you describe me please, how SP 2010 does this things automatically? I’ve found no built-in features for that.

Instead, I’ve created a simple visual web part to check and demonstrate that it can be done programmatically. This solution is able to synchronize user profile photo to and from the thumbnailPhoto Active Directory property:
Synchronizing user image between Active Directory and SharePoint profile
http://pholpar.wordpress.com/2010/08/10/synchronizing-user-image-between-active-directory-and-sharepoint-profile/

Peter

Reply

tb August 24, 2010 at 4:43 am

Hi, is it possible to synchronise the photo’s with Outlook 2007 and AD?

Reply

Mike Pfeiffer August 24, 2010 at 7:07 pm

No, you need OL 2010 to view the AD photos.

Reply

Prashant May 27, 2011 at 1:50 am

it’s possibe for Outlook 2003 and Outlook 2007 clients, by installing the Outlook Social Connector. The OSC is primarily aimed at enabling connections between social networks, such as Facebook and LinkedIn. However, out of the box it enables GAL photos to be displayed in both older versions of Outlook.

you can download it from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b638cc14-11e5-448a-b5a6-4f553ce81b94&displaylang=en

Reply

Scott September 9, 2010 at 9:17 am

Any chance of an ADSL example? I envision a user logon script that checks to see if the AD field is populated; if not, check a server share for a picture file named the same as the username and upload it to AD if one exists. We create photo badges for new employees, so those photos could be copied to the sever share and auto-populated into AD when the new user logs in.

Reply

Mike Pfeiffer September 9, 2010 at 9:35 am
Eric Laschinger May 6, 2011 at 9:20 am

Is this possible with Exchange Online (BPOS)?

Reply

Rubén October 13, 2010 at 8:21 am

Hi!

I have an Exchange 2003 running in a Windows 2003 R2. I follow your instructions and the photos shows in adsiedit.msc but doesn’t in outlook 2010. I read somewhere that it’s needed to prepare the AD to 2008 with “adprep32 /forestprep” and “adprep32 /domainprep /gppre”. The “adprep32” tool is in the 2008 CD “\sources\adprep”.

I hope i can help someone with this problem ;)

Reply

Gary Levell March 31, 2011 at 8:11 am

We have a free product available from our website that makes this very easy. http://www.exclaimer.com/products/outlook-photos/Default.aspx

Reply

Mike Pfeiffer March 31, 2011 at 4:08 pm

Cool, didn’t know about this product thanks for the information.

Reply

rush May 17, 2011 at 7:50 am

Hy!
I have problem! So, I must export list user with picture! picture is very ipmortant! How can I do that and export list??

Reply

Mike Pfeiffer May 17, 2011 at 8:00 am

To determine the users with a photo defined:

Get-ADUser -Filter * -Properties thumbnailPhoto | ?{$_.thumbnailPhoto}

To export to a text file, select whichever properties you want and pipe to Out-File:

Get-ADUser -Filter * -Properties thumbnailPhoto | ?{$_.thumbnailPhoto} | Format-List Name,SamAccountName | Out-File c:\userphotos.txt

Or export to CSV:

Get-ADUser -Filter * -Properties thumbnailPhoto | ?{$_.thumbnailPhoto} | Select-Object Name,SamAccountName | Export-CSV c:\userphotos.csv -NoType

Reply

daud July 23, 2011 at 3:53 am

Hi, I succesfully did the steps provided, and ran the ps command without problem but still can’t see picture of a user in OAB.
Environtment: DC win 2003 SP2 + ADWS and ADWS hotfix, exchange2007.
Anything i missed?

Reply

Leave a Comment

Previous post:

Next post: