Manage Exchange 2010 Thumbnail Photos with a PowerShell Based GUI

by Mike Pfeiffer on May 18, 2010

One of the new features in Exchange 2010 is the ability to import thumbnail photos into Active Directory. When you import a photo for a user into Active Directory, the image can be displayed in Outlook email messages and the global address list. You can manage thumbnail photos using the Import-RecipientDataProperty and Export-RecipientDataProperty EMS cmdlets.

While this is a very useful new feature, it is likely that entry level support techs or HR personnel that are not yet PowerShell savvy will be responsible for managing thumbnail photos. So, I've written a PowerShell based application using PrimalForms 2009 that provides a graphical interface to these cmdlets.

How Does It Work?

It's pretty simple. Go through this Exchange Team blog post to get your environment configured. Next, you need to download the script from here and save the code to a file with a .ps1 extension. Of course, the user running the application will need to be assigned the appropriate permissions.

The only other requirement is that you run the script from a machine running PowerShell v2. If you do not have the Exchange tools installed, the script will detect this and import the EMS cmdlets from an Exchange server in the local AD site (I blogged about how to do this a while ago in this post). Take a look at the following screen shot and the steps that explain how to use the application:

  1. Select a Mailbox. Type a name (you can use wild cards) and click on Search. Highlight the mailbox you want to configure in the results pane.
  2. Select a Photo. Click on Browse and navigate to a .jpg file that you want to use for the user. This should be no larger than 10k. Also, keep in mind that the recommended thumbnail photo size in pixels is 96x96 pixels.
  3. Upload a New Photo. Once you've selected a mailbox and a photo, click on the Upload New Photo button to add the image to Active Directory.
  4. Preview Current Photo. You can click on the Preview Current Photo link after selecting a mailbox to see the current image in the Photo Preview window. The Photo Preview window will also display photos that you browse to on your machine so you can see them before uploading them.

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

In my environment, it takes about 10-15 seconds to import the EMS commands into the local PowerShell session. Because of this, I added a message before the main form loads telling the user to "please wait" while the application is started. If the Exchange tools are installed and/or the commands have already been imported into your PowerShell session then you will not see this message.

What Else?

What functionality you would add to this tool? What other PowerShell based GUI tools would you build (or like to see built) to support your Exchange environment?

Update: If you want to modify this in PrimalForms you can download the script with the .pff file from here.

Related Posts

{ 9 trackbacks }

Tweets that mention Manage Exchange 2010 Thumbnail Photos with a PowerShell Based GUI -- Topsy.com
May 18, 2010 at 5:11 am
Outlook 2010: Photo Sizing Tool | The Little Things
February 1, 2011 at 7:35 am
faq-o-matic.net » Bilder im Active Directory?
February 6, 2011 at 10:15 pm
» Visualizzare le foto in Outlook 2010 e nella GAL di Exchange 2010 icubed portal
February 11, 2011 at 8:06 am
Adaugarea pozelor in AD folosind Exchange Management Shell » RO Windows Administrators Weblog
May 31, 2011 at 7:24 am
Ajouter des photos pour Lync Server 2010 et Exchange Server 2010 « Exchange your Mind
September 15, 2011 at 3:42 am
Add Outlook thumbnail pictures to AD « Exchange Adventure's
November 23, 2011 at 4:11 am
2K3 - Kontakt auf einmal mit Foto - MCSEboard.de MCSE Forum
February 1, 2012 at 2:46 am
Képek a címtárban « DefaultGateway
February 24, 2012 at 4:13 am

{ 52 comments… read them below or add one }

Robert Schleicher June 2, 2010 at 4:55 am

First I would like to say thanks for your hard work. I would love to be able to use this tool.

I am hoping you can help me out. When I run the script I get this error:
Cannot bind parameter ‘ConnectionUri’. Cannot convert value “http:///Powershell/” to “System.Uri”. Error: “Invalid URI: The hostname could not be parsed.”

After I select OK, the form does show up but when I try to search on a name I get this error:
The term ‘Get-Mailbox’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

This is from a Windows 7 x64, I also get the same error on a Windows XP x32.
Thanks for any help and of course thanks again for the tool.

Reply

Mike Pfeiffer June 2, 2010 at 5:11 am

Hi Robert,

It looks like it’s not finding your Exchange server. The script searches the current AD site for potential servers to connect to. Are the IP subnets used by the PCs defined in AD?

Try this…

1. Comment out line #97
2. On line #109, replace $fqdn with the FQDN of your Exchange server.

Reply

Robert Schleicher June 2, 2010 at 7:46 am

WOW! What response time.
I did what you recommended and I get another error:
Cannont validate argument on parameter ‘Session’. The argument is null. Supply a non-argument and try the command again.

I should have said this on my first post. We are running Exchange 2007 SP2 not 2010. I was hoping your tool would still work in this environment too (I figured this since AD already has the attribute thumbnailPhoto). I would just like to get the pictures in AD so when we upgrade to 2010 we will have that piece done.

If this script requires 2010 I appologize for wasting your time and not mentioning it earlier.

Reply

Mike Pfeiffer June 2, 2010 at 7:56 am

Robert, yeah this requires the Exchange 2010 Management Shell. The Import-RecipientDataProperty cmdlet is specific to Exchange 2010 and that’s what the script uses to import the photos.

Reply

Robert Schleicher June 2, 2010 at 7:46 am

I forgot to add that my IP Subnets are in AD.

Reply

Chris June 8, 2010 at 8:14 am

Is there an easy way to remove a picture?

Reply

Mike Pfeiffer June 8, 2010 at 9:56 am

There are only Import and Export cmdlets for the photos and unless I am missing something obvious, I don’t see a way to simply remove a picture. You should be able to clear the users thumbnail photo attribute value using ADSIEdit and that would remove the picture.

Reply

Norbert June 12, 2010 at 8:55 am

It should be able to clear the attribute:
http://msexchangeteam.com/archive/2007/10/19/447301.aspx
Maybe worth a try adding this to your gui.

Reply

Chris June 21, 2010 at 8:19 am

The command to remove a picture is: Set-Mailbox (username) -RemovePicture

Reply

Mike Pfeiffer July 7, 2010 at 9:18 am

Thanks Chris, I didn’t know about the RemovePicture parameter on the Set-Mailbox cmdlet.

Reply

Fred July 3, 2010 at 6:08 am

Im very new with exchange 2010. The only issue Im having is how to create New Mailbox Database under Data Management. When I try to create I will to find the server but nothing comes up. I also tried the EMS with this line.

New-MailboxDatabase -Name “MailboxDatabase01″ -EdbFilePath D:\DatabaseFiles\MailboxDatabase01.edb

Then it prompts for server. Type in server then tells me “couldnt perform the operation b’cause the server “server”isn’t a mailbox server.

Any suggestions is much appreciated. Thanks.

Reply

Benjamin Nias July 9, 2010 at 6:32 am

Hi Mike,

Brilliant! Was holding off implementing this due to the admin it would take – now I can get HR to do their own work ;-)

Couple of questions I was hoping yoiu could help with.

1. What permissions need I give a user or group (HR) on the Ex2010 server to allow the script to run?
2. I had initially added a test photo manually but whilst it UL’d fine the image doesn;t appear in Outlook2010. It was searching for answers that I found your script. The tool confirms the image is UL’d and in AD but no-go in Outlook. Any idea or suggestions as to where I should start looking?

Thanks again, great, great tool!

Benjamin

Reply

Mike Pfeiffer July 9, 2010 at 8:11 am

Hi Benjamin, thanks for your comment.

1. You’ll need to use RBAC to assign the Import-RecipientDataProperty and Export-RecipientDataProperty EMS cmdlets to your staff. You can create a custom role or use the existing Migration role that contains those cmdlets.

The docs on RBAC can be found here:
http://technet.microsoft.com/en-us/library/dd298183.aspx

2. As far as the photo not showing up in Outlook, are you working in online mode or cached mode? If you’re working in cached mode, you’ll want to follow the steps at the end of this article to configure the OAB:
http://msexchangeteam.com/archive/2010/03/10/454223.aspx

Reply

Benjamin Nias July 13, 2010 at 5:29 am

Hey Mike,

Brilliant. I had to enable PS scripts on the client systems as per this link:
http://www.itexperience.net/2008/07/18/file-cannot-be-loaded-because-the-execution-of-scripts-is-disabled-on-this-system-error-in-powershell/

but we’re now rocking. Thanks a lot for your help and the tool!

Benjamin

Reply

Mike Pfeiffer July 13, 2010 at 5:32 am

Excellent, thanks for the update :)

Reply

Harald Steindl July 16, 2010 at 12:57 am

Hello!

Thanks for the great script. However I cannot get it to work under Server2008/Exchange 2007.
The Import-RecipientDataProperty cmdlet is not found although it seems to work for other people.
See here: http://blogs.technet.com/b/ilvancri/archive/2010/01/08/follow-up-import-recipientdataproperty.aspx
Any idea how to get the cmdlet running?

Reply

Mike Pfeiffer July 16, 2010 at 5:27 am

Hi Herald,

The Import-RecipientDataProperty cmdlet is an Exchange 2010 cmdlet, so that is why it’s not working for you on Exchange 2007. You could use AD PowerShell or the Quest cmdlets to import the photos manually. See the following links for examples:

http://www.mikepfeiffer.net/2010/06/how-to-use-ad-powershell-to-manage-outlook-2010-user-photos-with-previous-versions-of-exchange/

http://technodrone.blogspot.com/2010/06/updating-pictures-for-users-in-ad.html

Reply

Marc Papier July 21, 2010 at 10:54 am

I have completed these steps and the photos appear in various places within outlook except for in the top, right of a message. We are using Exchange 2010 and Outlook 2010. If I have the people pane on, it displays in the bottom, among other places. Any thoughts?

Reply

Damian September 21, 2010 at 6:11 am

Dear Mike,

We use Exchange 2010 and SharePoint 2010. We are in the process of uploading profile images to the AD so that they are displayed in the AD. I was wondering if there is a way of ensuring that both GAl and Sharepoint profile images are obtained from the same source? If so what is the ebst way of achieving this?

kind Regards

Reply

Mike Pfeiffer September 21, 2010 at 3:56 pm
Jon Halseth October 6, 2010 at 2:37 pm

I uploaded all the thumbnail into the attribute. I can see them on a windows7 running outlook 2010 with my (domain admin) account. I am unable to see the pictures on a different (user) XP computer running Outlook 2010. Is there something special I have to do to make them work on my legacy XP machines? I did add windows search from my initial error but that did not correct the issue. I tried my account on the XP machine and all the thumbnail pictures are grayed out. I am missing something. Thanks

Reply

Paul Yearron November 5, 2010 at 7:10 am

I have run these steps and checked again and again but cannot get the thumbnails to show when the user is on our new Exchange 2010 server. We are in the process of migrating and those users who are using Outlook 2010 with their mailbox on our old exchange 2003 server are able to see the photos for users who have been migrated. However if I then Migrate a user from 2003 who was able to see the pictures to exchange 2010 then they are no longer able to see user thumbnails. Any ideas – I am stumped.

Reply

Paul Yearron November 9, 2010 at 7:27 am

Further investigation is now showing that a local copy of outlolok 2010 shows the thumbnails but when running outlook 2010 over citrix or even ruuning outlook on the citrix server itself does not show pictures.

Reply

Paul Yearron November 10, 2010 at 3:12 am

I have now found out that on Citrix we are not using cached mode, whereas locally we are. I have disabled cached mode locally and now no longer get the pictures. So how can I get the photos to display when not in cached mode,

Reply

Dave wilga November 19, 2010 at 6:50 am

I have modified AD, even changed the value for thumbnailphotoindicator. I am able to populate AD with photos, and retrieve them from AD manually. I’ve even found a nice GUI for either editing, or double-checking the presence of the correct photo within AD at http://www.cjwdev.co.uk/Software/ADPhotoEdit/Info.html

However, for some odd reason I am unable to retrieve those same AD photos from within Outlook 2010. Outlook only seems to display photos from my personal contacts list, not AD. Any Thoughts?

Reply

Chris128 December 1, 2010 at 5:18 pm

@Dave wilga – Can you just confirm you have run “AdPrep.exe /forestprep” from the Server 2008 disc to extend the AD schema? That was literally all I had to do on my test domain when I first tried this feature out.

PS. I wrote AD Photo Edit, glad to hear you think it is nice :) I actually had no idea about this powershell based GUI that Mike has made until today.

Reply

Dave Wilga December 8, 2010 at 8:40 pm

@Chris128 – Yes, we have run the appropriate ADPrep / ForestPrep and have confirmed that the corresponding correct MAPIID is in AD. Tonight, a coworker had briefly been able to retrieve photos on a new install of Office 2010 under XP. But after a reboot, no more photos. It now appears that its a permissions/Group Policy issue, but I’m lost as to where to look next.

…and thanks for a GREAT tool. It was the first one I found, so I can’t compare it to others, but from what I see there is no need to use any other tool anyway.

Reply

Chris128 December 9, 2010 at 11:12 am

Hmm that does sound odd, I guess the only thing you can do to get any further is build a blank new XP machine with Office 2010 on it and stick it in a test OU that has no GPOs at all applied to it, then assuming that works fine, link each of your standard GPOs to that OU one by one until it breaks. Not fun, but I can’t think of any other way to narrow it down really without seeing your exact setup.

Oh and thanks again for the kind words about AD Photo Edit. Personally I think it is better than any of the other tools available at the moment (and certainly much cheaper, especially if you are using the free version of course!) but of course I would say that :)

Reply

it is very good tool December 15, 2010 at 1:19 am

Thank you for your such a powerfull script and usefull. without having exchange 2010 able to add photos in extisting active directory and it is working fine.thanks

Reply

Herbert Knavs January 5, 2011 at 4:37 am

Hi all, I troubles with showing photos in Outlook.
I have Server 2008 R2 DC (of course I have run adprep /forestprep and adprep /domainprep /gpprep).
MAPIID is correct on the thumbnailphoto.
Also have Exchange 2010 and been used Exchange PS comandlet to import jpg picture which is 96×96 and about 2K in size.
No luck.
After I have changed OAB thumbnailphoto attribute from indicator to value, regenerate OAB.
Downloaded new OAB to Outlook 2010 and still no luck.

Do anyone has any idea what went wrong?

Thanx in advance

Reply

Craig January 19, 2011 at 3:16 am

Hi Everyone

I had this working so well on Exchange 2010 and AD 2003. I then update Exchange to SP1 and none of the photos are being displayed.

I have even created new users and via the cmdlet added a photo. Still no joy.
Any ideas?

Reply

Christian January 26, 2011 at 3:24 pm

Hi Craig, I’ve created an script who load the email direction (because I hve multiples domains and the mailbox was the only unique attribute that I found) but to run it I need to use the Powergui tools and the exchange cmdlets.
Do you have any ideas if I can run the script using only the exchange cmdlets?

thanks a lot man, I’ve a blog like yours but in spanish :)

this is the code (everyone can use it if they want :) )

#Variable directorio donde se encuentran las fotos.
$PhotoPath = ‘c:\Fotos\’
$DestPhotoPath = ‘c:\RespFotos\’
#Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
clear
Write-Warning ” ## Esta acción actualizará todas las fotos del directorio c:\fotos\”
Write-Warning ” ## Todas las fotos deben contener el correo electronico principal del usuario”
Write-Warning “Esta seguro de querer actualizar todas las fotos(S/N)?”
$Opcion = Read-Host
If ($Opcion -eq ‘s’) {
ForEach ($TempFile in Get-ChildItem $PhotoPath | Where-Object { $_.Extension -eq “.jpg” } )
{
$Mailbox = $TempFile.Name.substring(0, $TempFile.Name.Length – 4)
Write-Host ‘Iniciando carga de imagen para’ $Mailbox -ForegroundColor yellow
$DN = get-mailbox -filter ‘primarysmtpaddress -eq $mailbox’ | select DistinguishedName
$TempPhotoPath = $PhotoPath + $Mailbox + ‘.jpg’
Import-RecipientDataProperty -Identity $DN.DistiguishedName -Picture -FileData ([Byte[]]$(Get-Content -path $TempPhotoPath -Encoding Byte -ReadCount 0))
Move-Item $TempPhotoPath $DestPhotoPath
} }
Else { Write-Host “No se han hecho cambios” ; Exit }

Reply

Shawn March 7, 2011 at 12:16 pm

Is it possible to import photos into the Exchange GAL for Groups?

Reply

Mike Pfeiffer March 7, 2011 at 3:47 pm

No, just mailboxes or contacts.

Reply

tkadd February 23, 2012 at 2:51 am

what if the group is a distribution group and does have a mailbox?? can we import photo for it???
if yes shall we use the same command for a contact?
Import-RecipientDataProperty -Identity $DN.DistiguishedName -Picture -FileData ([Byte[]]$(Get-Content -path $TempPhotoPath -Encoding Byte -ReadCount 0))

or is it a different command???

Reply

Quint March 25, 2011 at 3:10 am

Mike,

thanks for the work, this is very userful for us!

But is would be even more useful if you could provide the pff file.
Can you?

We are also using PrimalForms and i would like to package this script.

Thnx and regards,

Quint

Reply

Mike Pfeiffer March 25, 2011 at 8:46 am

I’ve added an update to the end of the post that includes a link to a zip archive containing the script and the .pff file.

Reply

Ken Mabus March 26, 2011 at 4:50 pm

Uploaded photo just fine. However, it will not display! Anything to check here?

Reply

Mike Pfeiffer March 29, 2011 at 8:13 am

Have you extended the schema in your forest/domain? See the comments here http://blogs.technet.com/b/exchange/archive/2010/03/10/3409495.aspx on the Exchange Team blog.

Reply

Grybal July 20, 2011 at 4:12 am

Hi,

how can I make “*.jpg” file less than 10K ?

Michal

Reply

Mike Pfeiffer July 20, 2011 at 7:06 pm
sri August 30, 2011 at 12:19 am

Hi,

i need help Manage Exchange 2010 Thumbnail Photos with a PowerShell Based GUI please provide me step by step configuration.

Reply

Ariel September 7, 2011 at 12:40 pm

how I can add photo to AD groups to see it in the Outloock 2010 ????? thanks

Reply

Jason January 12, 2012 at 9:44 am

I have everything working for importing photos. My photos are set as a value for my cached clients to download them in the OAB. However, i have had a few remote staff ask for their photo to be changed. I have changed their photo and it displays correctly for all online users, and cached users that have not added that person as a local contact. However, if the user is a local contact the photo never updates (even if you update the GAL and distribtuion services, download the lasted GAL to the end users machine, open the contact, select and remove the picture and click update). It still shows the old photo for the cached user. The only way i can get it updated is to have them remove their local contact and readd them which seems wrong. How can i force local contacts to check against the GAL or at least update properly when manually updating photos.

Reply

Welly Kev January 18, 2012 at 3:33 pm

Great tool. Keep up the good work

Reply

Mike Pfeiffer January 18, 2012 at 4:11 pm

Thanks!

Reply

amy January 26, 2012 at 9:41 am

I uploaded the photos and can see them in the contact info if i hover over their name but it doesn’t show in the email on the right side for all users. Any ideas?

Reply

Carsten Radke January 29, 2012 at 11:15 am

Do you have a function to list all users who has or who has not a photo in the ad with export to a txt-file ?
I need it for a list to know witch users doesn’t have a photo.

thanks, Carsten

Reply

Mike Pfeiffer January 30, 2012 at 6:54 pm

Try this:

Get-Mailbox -ResultSize unlimited | ?{!$_.haspicture} | select Name | out-file c:\nophoto.txt

Reply

Carsten Radke February 2, 2012 at 9:50 am

simply brilliant, thanks a lot

Reply

jayal February 27, 2012 at 10:22 pm

Is there any scripts for Exporting thumbnails form AD/Exchange?If any scripts or any Commands then please post It.

Reply

Sam May 8, 2012 at 2:33 pm

I used this great tool awhile back with no issues. Since I have had more users and the need to upload their photos, when I try to search now I only get an error stating “Could not find any Domain Controller in the domain” what would cause this?

Thanks for your time!

Reply

Leave a Comment

Previous post:

Next post: