Uploading Active directory thumbnail photo by using power shell

Hi again

Today I’ll post about how to upload thumbnail potos to AD, where Exchange and Lync will use this potos into their systems. For doing this you should have at least one of the domain controller run on Windows server 2012 R2.

First you have alias name of all the active directory users and save this file as csv format. Another thing you have passport size photograph for all the users, the size should be less than 10 KB otherwise photo’s won’t appear in the search directory and save these photos by using the alias name and put the photos and csv files in the Windows server 2012 R2 domain controller.

In a DC open a AD powershell as an administrator and type the following:


$photo = [byte[]](Get-Content “C:AD Pictures10288.jpg” -Encoding byte)

#(C:AD Pictures10288.jpg which is the path of the photo directory in the domain controller)
#Run below command for the photo uploading

Set-ADUser "domainusername" -Replace @{thumbnailPhoto=$photo}

#For batch uploading photos use the below command

$ListOfUsers=import-csv “c:adpicturesadpictures.csv”
Foreach($User in $ListOfUsers)

PS C:Usersadministrator>

{

$photo = [byte[]](Get-Content “C:ADPictures$($user.identity).jpg” -Encoding byte)
Set-ADUser $user.identity -Replace @{thumbnailPhoto=$photo}

}

That’s all, hope that helps!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s