Setup and use the GAL Photos feature using Exchange 2007 [Updated]

If you’re not using Exchange Server 2010 yet, then you might wonder if you can take advantage of some of the newer features available in Outlook 2010. While mailtips, personal archives and automatic mailbox mappings aren’t possible, you can make use of the GAL photo feature.

It’s fairly painless to enable this and the setup steps for your organisation are the same as Exchange 2010. Once you’ve sorted the org pre-requisites, then the only piece missing is the cmdlets to import the photos. Although you can use Sharepoint 2010 to do this (and delegate it to end-users), I thought it would be useful to have a simple drop-in Powershell script that can accomplish this in the same way as you can in Exchange 2010.

Getting Active Directory Ready

The AD pre-requisites are fairly simple. You need to ensure the attribute the photo is stored in is replicated to the Global Catalog, and ensure you have either a Windows Server 2008 or later Domain Controller in your domain, or simply prepare your Windows 2003 forest schema for 2008:

  1. If you are in a multi domain environment, follow “A minor schema change” in the Exchange Team blog post GAL Photos in Exchange 2010 and Outlook 2010. If it’s a single-domain environment you’re all set.
  2. If you don’t have at least one Windows 2008 / 2008 R2 Domain Controller, you need to run adprep /forestprep from the 2008/2008 R2 setup CD as described in the article Prepare a Windows 2000 or Windows Server 2003 Forest Schema for a Domain Controller That Runs Windows Server 2008 or Windows Server 2008 R2. You don’t need to install a Windows 2008 / 2008 R2 domain controller, just update the schema. More details on why this is required here.

Importing Photos

In Exchange 2010, you use the Import-RecipientDataProperty cmdlet to import photos. This command isn’t provided in Exchange 2007 so I’ve written a short Powershell script that can do this for you. It’s usage is almost identical to the Import-RecipientDataProperty cmdlets, except that you don’t need to specify which property to import (obviously) and you don’t need to do submit the file as a byte-encoded array – you just give the filename.

Usage is simple:

.\Import-Picture.ps1 -Identity stevegoodman -Path .\Steve_96x96.jpg

Then, once AD has replicated, the Offline Address Book is updated (for example, using Update-OfflineAddressBook “Default Offline Address Book”), and clients have downloaded the new OAB, photos should now show in Outlook 2010 (or 2003 and 2007 – check my previous article!)

Removing Photos [New]

If you want to remove a photo from a contact, you need to clear the relevant attribute in Active Directory. As above, I’ve provided a script that can do this – for example, to clear the GAL picture:

.\Clear-Picture.ps1 -Identity stevegoodman

The Import-Picture.ps1 and Clear-Picture.ps1 Scripts


param($Identity,$Path);
#
# Import a JPEG file into Active Directory for use as the Exchange / Outlook GAL Photo
# Best results - Under 10K, 96 x 96
#
# Steve Goodman
if (!$Identity)
{
throw "Identity Missing";
}
if (!$Path)
{
throw "Path Missing";
}
if (!(Get-Command Get-User))
{
throw "Exchange Management Shell not loaded";
}
$User = Get-User $Identity -ErrorAction SilentlyContinue
if (!$User)
{
throw "User $($Identity) not found";
}
if (!(Test-Path -Path $Path))
{
throw "File $($Path) not found";
}
$FileData = [Byte[]]$(Get-Content -Path $Path -Encoding Byte -ReadCount 0);
if($FileData.Count -gt 10240)
{
throw "File size must be less than 10K";
}
$adsiUser = [ADSI]"LDAP://$($User.OriginatingServer)/$($User.DistinguishedName)";
$adsiUser.Put("thumbnailPhoto",$FileData);
$adsiUser.SetInfo()


param($Identity);
#
# Clear the GAL Picture attribute
#
# Steve Goodman
if (!$Identity)
{
throw "Identity Missing";
}
if (!(Get-Command Get-User))
{
throw "Exchange Management Shell not loaded";
}
$User = Get-User $Identity -ErrorAction SilentlyContinue
if (!$User)
{
throw "User $($Identity) not found";
}
$adsiUser = [ADSI]"LDAP://$($User.OriginatingServer)/$($User.DistinguishedName)";
$adsiUser.PutEx(1,"thumbnailPhoto",$null)
$adsiUser.SetInfo()

Download E2007-Picture.zip

Finally, if you have any problems or questions, let me know as usual in the comments…

35 thoughts on “Setup and use the GAL Photos feature using Exchange 2007 [Updated]

  1. Hi Steve,
    i few questions with regard to the above script for have photos show up in gal for exchange 2007, i tested at my environment and it works well. I needed if this configuration is supported by MS and also how can i bulk import for say all user’s in single DB / or server.

    Regards
    Sathya

  2. Great script! This has worked for all of our management staff except for one user. Only one user is generating an error using this script while all others are just fine.

    Any idea how to correct this one?

    The following exception occurred while retrieving member “Put”: “Unknown error (0×80005000)”
    At C:\Image\output\Import-Picture.ps1:34 char:14
    + $adsiUser.Put <<<< ("thumbnailPhoto",$FileData);
    + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

    The following exception occurred while retrieving member "SetInfo": "Unknown error (0×80005000)"
    At C:\Image\output\Import-Picture.ps1:35 char:18
    + $adsiUser.SetInfo <<<< ()
    + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

  3. For those that are having issues with getting the images to display in the Global Address List, try closing Outlook and deleting this folder:

    C:\Users\%username%\AppData\Local\Microsoft\Outlook\Offline Address Books\

    This will force Outlook to re-download all of the OAB files – for me this fixed all issues with regards to image inconsistencies and Outlook not updating personal contacts with the new AD pictures!

  4. Hi Steve!

    good article,

    I did all those steps and my picture still not appears in the outlook,

    I have a outlook 2010 and a echange server 2007,
    the thumbailphoto attribute is set to replicate,
    I manually converted a 5k jpeg image to hex
    and I paste the hex code directly to the attribute ussing ADSI Edit
    is that wrong?

    where i work there are a lot of users with the picture well displayed
    so the feature is enabled and we know that is working

    i need to do something else? I waited for more than 72hs the replication,
    so itsn’t a replication issue

    Thanks and Regards,
    Adán.

  5. First off, this script has been a life saver, thank you for it. It’s worked for all 300 clients so far except for one.

    I’m getting this error on a new hire and I can’t figure out why, any chance anyone has seen this error?

    The following exception occurred while retrieving member “Put”: “Unknown error (0x80005000)”
    At C:\Image\output\Import-Picture.ps1:34 char:14
    + $adsiUser.Put <<<< ("thumbnailPhoto",$FileData);
    + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

    The following exception occurred while retrieving member "SetInfo": "Unknown error (0x80005000)"
    At C:\Image\output\Import-Picture.ps1:35 char:18
    + $adsiUser.SetInfo <<<< ()
    + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

    • Awesome script!

      I am having the exact same problem with one user as well. Did anyone face the same problem? Potential fix?

  6. Very good post.

    I’ve been able to figure out how to use this and upload pictures to our AD. and also remove them when requested.

    Thanks a Lot Works just great!!

  7. Great script. I have about 100 users who need to be imported. I used your GALBatchConvert and all of the files are saved as SAMAccount.jpg. Curious if there is a simple mod to your script to upload the entire folder?

  8. ok so I figured out my problem. Even though I had a Windows 2008 DC in the environment I had not previously run the schema update.

    Just ran the schema update and we have photos!
    Thanks again Steve

  9. Thanks Steve for this great post and your other post about OCS and Outlook 2003+2007.

    I have rolled out photo’s for all AD users but have not yet seen one pop up in Outlook 2010 or 2007 (with OCS). I used both your script and this snapin which someone from another forum wrote to upload photos inside the Active Directory and Computers MMC which works great. I recommend this to make uploading pictures easier: http://www.dewdney.co.uk/adext/adext.zip

    I have not seen any errors on Exchange 2007 even after increasing the OAB debug level. I have also enabled the setting “Replicate this attribute to the Global Catalog” inside the schema snap in. There were also no obvious errors in event viewer.

    Do you have any other suggestions on what I can check or debug to turn on to find whether the problem is?

    (I am making the assumption because the thumbnailPhoto attribute exists my schema is fine)

  10. Hi Steve,

    In my org one of my User can see the sender picture at the bottom for one day and next when he log on he is unable to see the photo below. What could be the cause this is happening for only this user others are working fine.

    Exchange 2007 SP3
    Outlook 2010
    Windows 7

    Regards,
    King

  11. hi Nice artical and neatly discribed
    but i just want to know how to upload multiple users photos via script is thery any method like CSV etc;
    in EXhange 2010 there is possible via CSV file but what about Exchange 2007
    can any one shade lite on this …
    souloution is highly aprriciated

  12. Hey there,

    Great post there, just what I was looking for!

    I am pretty much interested in this topic. I researched a lot of data online to seek for valuable information on this subject. Your resource is really informative, and I enjoyed how you summarized the info.

    I am looking forward to more posts from you, and will make sure to check back later!

    Thanks!

  13. Love your script. Works fine on my test environment. (Win 2008 Domain Function and Exchange 2007 SP3).

    I wonder if we can automate the process (loops) for automatic upload of pic with username.jpg. I will try it out and if I figure out i will pass the info here :)

  14. Sorry to bug again.. I can’t seem to get past this point…

    Both scripts work as I am able to see the jpg being added and removed in the AD attribute, with that said, I send and receive the OAB, I even went beyond that and tried to update the OAB in Exchange, but I still don’t see the profile pic being added to the profile when I pull up the profile in question. We are using Outlook 2010 with Exchange 2007.

    Would you happen to have any further advice as to why I might not see a profile pic when emailing the contact? (which is currently myself for testing purposes.) Are there any other break points one should consider or is this typically a cookie cutter solution?

    Thanks Again :)

    • Hiya,

      It should work – though it can take a little time as you are relying on a number of things to replicate and update – namely the schema changes, jpg to replicate through AD where necessary, and then the OAB updates, which once complete require Outlook to download the updated OAB.

      If you’ve done all the steps and double checked everything, then theoretically it should work – sometimes you have to wait a little while though before it finally takes effect. I remember first trying it on Exchange 2010 and going through all the updates and thinking it didn’t work, then the next morning opening Outlook and it was working.

      Steve

  15. Hello, Thanks for a great article :)

    My apologies for being a newbie…but I do have one problem when I run the power script, I get a return error that it could not locate the recipient… Should I be adjusting the script with any of my environment values?

    On a command line level I inputted:
    .\Import-Picture.ps1 -Identity -Path .\.jpg

    for testing purposes I have the ps1 and the jpg in the same folder.

    Am I missing something?

    Thank you in advance for your assistance.

  16. Hello. Let me Thank to author for this great info.
    Wonder, did the anybody make this for groups?
    it would be nice to have pictures for distribution groups!

  17. Hi,

    we did this but there is a little bit complex environment here. This is a hosted Exchange 2007 environment with w2k8 DCs.

    every customers has its own global address list and offline address book and every customer can see its users in them.

    But when I imported my photo, I saw that another customer can see my photo when I send an email to its users.

    So I think when I send an email to them, Outlook does not care whether I am in his offline address book and just checks the active directory online and displays the photo.

    This means that if you are in same AD everyone can see your photo if you send mail to them.

  18. Pingback: FAQ по Microsoft Exchange Server » Как добавить фотографии сотрудников в Глобальный адресный список(GAL) в Outlook?

  19. Hi Steve,

    Its a beautiful script, thanks for the same.

    I have a query. I have Exchange 2007 R2 and Outlook 2010 in our environment. I have used this script to upload photos and all users photos are showing address book. Now when a sender sends an email to more than 1 people, the receivers of the email can see only the photo of the sender but not the other recipients in that email. I tried to update OAB but no luck. Please let me know how can I make all the recipient photo visible in the email.

    Thanks,
    Amit

  20. Pingback: Habilitando o Exchange 2007 para o recurso de GAL photos « Rodrigo Rodrigues .:. www.andersonpatricio.org

  21. Pingback: Tweets that mention Setup and use the GAL Photos feature using Exchange 2007 -- Topsy.com

Leave a Reply