Tuesday, April 24, 2012

Upload picture in Outlook 2010 using the Exchange Management Shell (Exchange 2010)

The thumbnailPhoto attribute can accomodate photos of up to 100K in size, but the Import-RecipientDataProperty cmdlet won't allow you to import a photo that's larger than 10K

The original picture used in this example was 9K, and you can compress it further to a much smaller size - let's say approximately 2K-2.5K, without any noticeable degradation when displayed at the smaller sizes. If you store user certificates in Active Directory, the 10K or smaller size thumbnail pictures are comparable in size. Storing thumbnails for 10,000 users would take close to 100 Mb, and it's data that doesn't change frequently.

Set-Mailbox "Rachel Peach" -RemovePicture

Export-RecipientDataProperty -Identity "Rachel Peach" -Picture | ForEach {$_.FileData | Add-Content C:\exported\RachelPeach.jpg -Encoding Byte}
 
Note: The recommended thumbnail photo size in pixels is 96x96 pixels.

If you're on Exchange 2010 SP1, skip this step. The attribute is modified by 'setup / SchemaPrep'
  1. If you haven't registered the Schema MMC snap-in on the server you want to make this change on, go ahead and do so using the following command:
    Regsvr32 schmmgmt.dll
  2. Fire up a MMC console (Start -> Run -> MMC) and add the Schema snap-in
  3. In the Active Directory Schema snap-in, expand the Attributes node, and then locate the thumbnailPhoto attribute. (The Schema snap-in lists attributes by its ldapDisplayName).
  4. In the Properties page, select Replicate this attribute to the Global Catalog, and click OK. 
  5. Now you can start uploading pictures to Active Directory using the Import-RecipientDataProperty cmdlet, as shown in this example:

    Import-RecipientDataProperty -Identity "Zaw Htet" -Picture -FileData ([Byte[]]$(Get-Content -Path "C:\pictures\zawhtet.jpg" -Encoding Byte -ReadCount 0))

    Where are the pictures physically stored? In AD, in the db somewhere or in the user's mailbox on the Exchange server?
    - Information is stored in active directory database

     Remove Pictures from Outlook 2010
    Key: HKCU\Software\Microsoft\Office\12.0\Outlook\Options\Mail DWORD: ShowContactPicture Values:1 (or missing DWORD) = show contact picture if available 0 = do not show contact picture

    All you need to do is:
    File > Options > Contacts
    And uncheck the box next to "Show user photographs when available"
    Ok and then restart Outlook.