Inserting User Photos into AD and User Tiles with Powershell

10 Oct

I while back I wrote about importing images into AD with vbscript. I’ve recently been looking into doing a similar thing but found its now possible with powershell.

On server 2008 its pretty simple, I created a user photo directory and placed all the 200px x 200px user photos in there in jpeg format, saved as “firstname surename.jpg”, so it matches AD. I need to extend this script so it can run automatically and insert all the photos in the directory, automatically.

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

These photos should ll now appear in Outlook and can be used with Lync by running this powershell:

Set-CsClientPolicy -Identity PhotosControl -DisplayPhoto PhotosFromADOnly

Next was the tile images used in Windows 7 and Windows Server 2008+. It made sense to use the same image for this also, when the machine is locked, this is the image disaplyed, thankfully powershell to the rescue again.

Simply pop usertile.exe and usertile.ps1 in a shared location and set usertile.ps1 to be called as a login script in GP.

The powershell script is called when the user logs in, added via GP.

Next time the user logs in, the photo will be set.

That’s the easy part done, now to try and get mug shots of everyone 🙂

UPDATE: Or a much easier way is to just use this excellent free software from here.