How to use Active Directory user photos as account logon image in Windows clients 

Fan Fan 15,291 Reputation points Microsoft Vendor
2021-04-12T06:42:36.667+00:00

Apply to: Windows 7, Windows 8, Windows 10

The purpose of this Step-by-Step Guide is to use Active Directory user photos in Windows clients.
This guide contains instructions for user photos in Active Directory and steps to use it as a account logon image.

User photos are stored in the attributes of the user accounts in Active Directory. The photos can be used by applications like Outlook, Skype for Business (Lync) or SharePoint to display the picture of currently logged-in user in their interface.

There are three steps to use Active Directory user photos in Windows clients:

• Import photos into Active Directory
• Assign registry key permissions through Group Policy
• Deploy a logoff script through Group Policy
• Check the result
Step One: Import photos into Active Directory
Following PowerShell command can be used to complete the goal.

$ADphoto = [byte[]](Get-Content<path to file>-Encoding byte)
Set-ADUser<username>-Replace @{thumbnailPhoto=$ADphoto}

Just remember to provide an exact path to the image file and the user’s name, for example in my lab:
86659-4121.png
If you want to Set up photo for users in batch, a CSV file named photos.csv need to be prepared as following format:
AD_user, path_to_file
User1,C:\Photos\user1.jpg
User2, C:\Photos\user2.jpg
User3, C:\Photos\user3.jpg
Then the PowerShell command should be :

Import-Csv C:\Photos\photos.csv |%{Set-ADUser -Identity $_.AD_user -Replace @{thumbnailPhoto=([byte[]](Get-Content $_.path_to_file -Encoding byte))}}

In my lab:

86715-4122.png
86730-4123.png
Note: the path for the photos and csv file can be either a local path or a UNC path as in the screenshot.

Then you can check if the thumbnailPhoto attribute of the user has been set.
Open the Active Directory Users and Computers tool and make sure that Advanced Features options on the View menu is checked.
Right click the user and select the properties, then select the attribute Editor tag, check if the thumbnailPhoto attribute shows any value. If you see <not set>, it means there is no photo configured. Here are screenshots for your reference:
86745-4124.png
86686-4125.png
Note:
There is also one key point – the photo stored in the thumbnailPhoto attribute cannot be bigger than 100 kB, and the recommended size is 96 x 96 pixels.
Here is the most beautiful picture to be used in my lab.
86705-4126.png

Step Two. Add registry key permissions through Group Policy
Create a new GPO on the domain level.
86716-4127.png
Note: Assign the change account picture permission to users through the registry key. If users don't have the permissions, the scripts in step 3 would not work.
The registry key is under: MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users

Edit the GPO under Computer Configuration>Windows Settings>Security Settings>Registry as following:
Right click the Registry entry, and click Add Key:
86706-4128.png
Navigate to: MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users
86679-4129.png
Give FULL permission to users:
86751-41210.png
86649-41211.png
Click OK and close the Group Policy Management Editor.
To update Group policy, we need to restart the computers.

Step Three. Deploy a logoff script through Group Policy

For the script, you can refer to this one.
Note: This script is used to export the photo stored in the thumbnailPhoto attribute and saves it on your machine, in a specified folder (in this case: C:\ProgramData\AccountPictures{User SID}).

Copy the script content to your notepad and saved as filename.ps1; Put it into a shared folder. Users should have permission to read it.

Edit the GPO we created before.
Navigate to User Configuration>Windows Settings>Scripts
Double click the logoff
Click add option, enter the path of the script as following:
86687-41212.png
Click the option Show files, copy the file to the location:
86761-41213.png
Update the group policy : log off and login again.

Last, check the result. **
If the policy was applied, you will see the result on the clients where the users will logon to:
The photo stored in the thumbnailPhoto attribute would be exported to into a specified folder on your machine. **(C:\ProgramData\AccountPictures{User SID})

86771-41214.png

New registry keys will also be created under MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users{User SID} in the Windows registry, with paths to these photos.
86772-41215.png

And you will see the photo we configured on the logon image.
86736-41216.png

If you also want to use the photos, have a try!

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,112 questions
Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,843 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. John Brines 6 Reputation points
    2022-04-11T13:55:08.71+00:00

    Hi There @Fan Fan

    Nice article. I have followed it and I can see the photos added to the program data\account pictures. I can also see the registry entries have been made but still the photo isn't being shown at login.

    1 person found this answer helpful.

  2. syed 1 Reputation point
    2022-02-17T10:59:13.463+00:00

    @Fan Fan I have followed your step however I am not able to view the image on my computer ?

    1. I can see the images in registry but not in (C:\ProgramData\AccountPictures{User SID})
    2. I have enable the default account picture in the GPO which we have created.
    0 comments No comments

  3. Rune Jonassen 1 Reputation point
    2022-02-20T18:40:28.59+00:00

    It works as far as copying the script to Logoff folder. Access Denied.

    Which permissions do I need? Cant seem to find the correct one.

    Edit:

    Found the solution. Don't use UNC network path. Open folder locally and paste the file.


  4. Mateusz Grabowski 1 Reputation point
    2022-02-23T22:07:05.093+00:00

    For everyone who struggles with this tutorial:

    1. There is easier way then scripting to import pictures into AD. https://www.codetwo.com/freeware/active-directory-photos/ - it's free and (at least for me) it worked out-of-the-box
    2. Script from step "Three" isn't working with "just" copy-paste. In this script line $image_base uses different environment variable then what we need. On Classic Shell forum script has line $image_base = $env:public + "\AccountPictures" what means that it points on C:\Users\Public. That's why this line has to be replaced with $image_base = $env:ALLUSERSPROFILE + "\AccountPictures". With that changes (at least for me) it worked in first try.
    3. I suggest simple \Domain Controller\netlogon as a place to put script
    4. In GPO it's better to place this script into "Powershell scripts" instead of "Scripts".
    0 comments No comments