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
$photodir = "c:\temp\photo\"
$photos = Get-ChildItem -Path $photodir -Filter *.jpg
#itterate through Photos in Photo Directory
foreach ($photo in $photos)
{
#store the raw file content of the image
$jpg = [convert]::ToBase64String((get-content $photo.FullName -encoding byte))
$Name = (($photo.Name).split("@")[0]).Replace("."," ")
$LDAPString = "LDAP://cn=" + $Name + ",OU=OU1,dc=domain,dc=local"
$userAD = [adsi] $LDAPString
$userAD.put("thumbnailPhoto",$jpg)
$userAD.setinfo()
Write-Host "Updated User " $userAD.name " Thumbnail Photo"
}
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.
Login