My customer recently had some issues exporting Picture from SharePoint My Site to Active Directory using the ThumbnailPhoto attribute. What was happening is that User Profile Application was not exporting all pictures and Full imports were deleting all pictures that were already in Active Directory.
After some research I found a bug in SharePoint that had already been fixed in the Dec 2011 Cumulative Update, but during research and testing we played with scripting a solution just in case I was wrong (Working on a deadline that had already slipped)
Here is the script that I created it's very rough and needs error checking and as well as possible optimization but it was written with the hope to not be needed, as well there are some caveats that I want to make you aware of
This needs to be run on Windows 2008 R2 server so that I can install the Active Directory Module. You could install it yourself and change a few lines to get around that thought if you wanted.
I download all the pictures from the internet to the hardrive so make sure you have enough room to deal with that. I suggest estimating each picture at 100KB, as that is the max size for the attribute thumbnailPhoto.
I use 'GetUserProfileByIndex()' to create my list of profiles to download the picture from it was quick to implement but it only includes those profiles that have a My Site. This was fine for me, but depending on your implementation that may not be adequate. I hope to change this in the future.
The account that you run the script with needs write permission to the accounts that your editing.
The account $RunAsAccountName needs access to the user profile service.
With all that being said here is my script, please take it and make it your own. Remember to test it first and that I'm not responsible for any problems you may have, this is just a sample. With that being said I would love to hear ofany issues or improvements you may have.