In my role I work with a lot of demo environments, and so it’s not uncommon for me to find quick workarounds for tasks that I have to do repeatedly or train others to do. Recently one of those has been populating the thumbnailphoto attribute for Lync Server. For a while I was using a modified version of a script written by George Durzi, and the script below still uses most of what he wrote in his blog entry on the topic. I also borrowed the file dialog function from Hugo Peeters from his PeetersOnline entry and the AD bits from various places. That’s really how I “code” these days anyway – thank goodness for the internet.
I wrote this so that it works well in multi-domain environments like the one I work in, so it searches the global catalog to find the user wherever they may be and then does an LDAP bind to write to the domain where they are actually located since thumbnailphoto isn’t a global catalog attribute.
- To run, save the attached script and simply run the script from Powershell. If you are running it from a server you may need to install the Desktop Experience feature (servermanagercmd -i desktop-experience).
- To change it to work in your environment just modify line 2 to match your Active Directory domain. In case you’re not familiar with the syntax, domain.com would be dc=domain,dc=com and europe.domain.com would be dc=europe,dc=domain,dc=com.
- When you run the script you’ll be prompted for a username. This should be the logon name (samaccountname) of the user, i.e. mstacy rather than email@example.com.
- The photos can’t be larger than about 70kb (In my brief testing 67kb worked, 76kb didn’t). If the photo is too large you’ll receive this: "Exception calling "CommitChanges" with "0" argument(s): "A constraint violation occurred.
- Like all things on the internet, use at your own risk.
Other useful links related to photos in Lync and Exchange: