PowerShell: updating AD photo for use in Office 365

By | 15 March, 2013

I wanted to add a photo to every user in our Office 365 environment, so it is visible within our Lync software.
Normally I would think I would go to Lync, open op “Tools” and then “Options”, select My Picture and change it. But in Lync 2013 the “Edit or Remove Picture” is grayed out.
You can read some more about this “problem” in this support post. It will be available again when they upgrade our office 365 environment.

So for now I had to think of something.
As we have a synced environment (through DirSync) I thought I could make use of the AD User object property “ThumbnailPhoto”. If  I could fill this value with a jpg then it would get synced to office 365.
And for that I created a PowerShell Script.

Starting Point: I have a folder with all the JPG images which are named in the following format firstname.lastname@domainname.jpg (I got these from someone else, who saved them like that). So as u will see in the script below I had to use some string manipulation to match the JPG to a domain user

It will take some time before you see pictures.

I received the following error for a few images: Exception calling “setinfo” with “0” argument(s): “A constraint violation occurred. (Exception from HRESULT: 0x8007202F)”.

I noticed that the thumpnailphoto attribute can’t hold more than about 75kb. So make sure you’re images are smaller.

One thought on “PowerShell: updating AD photo for use in Office 365

  1. Pingback: Cambiar la foto del perfil de Office365 - Mario Cortés Flores

Leave a Reply

Your email address will not be published. Required fields are marked *