본문 바로가기

Windows Server

Update a user's photo in Active Directory (AD).

반응형

You can use PowerShell to update a user's photo in Active Directory (AD). Here are the steps to do this:

 

1.Connect to your AD: To connect to your AD, open PowerShell and run the following command:

 

Import-Module ActiveDirectory

 

2.Get the user: To get the user that you want to update, run the following command, replacing "UserName" with the name of the user:

 

$user = Get-ADUser -Filter "Name -eq 'UserName'" -Properties thumbnailPhoto

 

3.Update the photo: To update the user's photo, you need to convert the photo to a byte array and set the "thumbnailPhoto" property of the user object. Here's an example that updates the user's photo with a file named "photo.jpg":

 

$photo = [Byte[]](Get-Content -Path "C:\path\to\photo.jpg" -Encoding Byte)

$user.thumbnailPhoto = $photo

Set-ADUser -Instance $user

 

4.Verify the update: To verify that the photo was successfully updated, you can retrieve the user object again and inspect the "thumbnailPhoto" property:

 

$user = Get-ADUser -Identity $user.DistinguishedName -Properties thumbnailPhoto

$user.thumbnailPhoto

 

If the photo was successfully updated, you should see the byte array representing the photo.

 

These are the steps to update a user's photo in AD using PowerShell. By using PowerShell, you can automate the process of updating photos and perform other tasks related to AD management.

 

반응형