Profile pictures in local Active Directory

Add support for thumbnails in Active Directory

  • Download “AdExt.dll”  
  • Place it directly under C:\
  • Go to %WinDir%\Microsoft.NET\Framework64\ and open the folder for the latest version you have e.g “v2.0.50727”
  • Open CMD in this folder so that InstallUtil.exe can be accessed and run:
  • InstallUtil.exe c:\AdExt.dll

Change a single profile picture with PowerShell

If you just need to change a single photo for a single user you can use this command:

Set-ADUser Mary-Replace @{jpegPhoto=([byte[]](Get-Content "C:\pic.jpg" -Encoding byte))}

Download a single profile picture

We need to set the image as a variable first, then save the content as bytes to the computer.

$ADuser = Get-ADUser someusername -Properties thumbnailPhoto

$ADuser.thumbnailPhoto | Set-Content C:\Users\$env:UserName\Desktop\img.jpg -Encoding byte

Bulk download multiple profile pictures with PowerShell

We can download the profile pictures for all employees in a given OU with the following command.

First it makes a folder on the desktop, if it does not exist. Then it saves the profile picture for each user account in the OU to the folder.

$path = "C:\Users\$env:UserName\Desktop\AD profile pictures\"
If(!(test-path $path)){New-Item -ItemType Directory -Force -Path $path}

$ADusers= Get-ADUser -Filter * -SearchBase "OU=Finance,OU=Users,DC=abcompany,DC=local" -server abcompany.local -Properties thumbnailPhoto | ? {$_.thumbnailPhoto}
    foreach ($ADuser in $ADusers) {
    $name = $ADuser.SamAccountName + ".jpg"
    $ADuser.thumbnailPhoto | Set-Content "$path\$name" -Encoding byte

Make sure you replace server name and the correct OU in your AD directory.

Batch change profile pictures in Active Directory

If you need to bulk update the profile picture for multiple users in AD you can use this command. Note that here we have named each picture after the username of each user. So this is not really a sophisticated script, but it does the job if you are handy at Source code editor. Might improve on this later.

$photo1 = [byte[]](Get-Content 'C:\your_folder\username1.jpg' -Encoding byte)
Set-ADUser 'username1' -Replace @{thumbnailPhoto=$photo1}
$photo2 = [byte[]](Get-Content 'C:\your_folder\username2.jpg' -Encoding byte)
Set-ADUser 'username2' -Replace @{thumbnailPhoto=$photo2}
$photo3 = [byte[]](Get-Content 'C:\your_folder\username3.jpg' -Encoding byte)
Set-ADUser 'username3' -Replace @{thumbnailPhoto=$photo3}
$photo4 = [byte[]](Get-Content 'C:\your_folder\username4.jpg' -Encoding byte)
Set-ADUser 'username4' -Replace @{thumbnailPhoto=$photo4}


Leave a Reply

Your email address will not be published. Required fields are marked *