Set an image for user in AD

Set user images in Active Directory with PowerShell

John Savill

May 21, 2017

1 Min Read
Set an image for user in AD

Q. How can I easily set the image for an AD user?

A. The below PowerShell will easily set the users picture and also a thumbnail picture (if you have Exchange scheme extensions). Note in my example the image is 283x283 and the thumbnail is 96x96.

$photoFile = "E:tempfilessav283283.jpg"$thumbFile = "E:tempfilessav9696.jpg"$username = "johnsav"$user = Get-ADUser -LDAPFilter "(sAMAccountName=$username)"$photo = [byte[]](Get-Content $photoFile -Encoding byte)$thumbPhoto = [byte[]](Get-Content "$thumbFile" -Encoding byte)Set-ADUser $user -Replace @{jpegPhoto=$photo}Set-ADUser $user -Replace @{thumbnailPhoto=$thumbPhoto}


About the Author(s)

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like