Skip navigation
Set an image for user in AD

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:\tempfiles\sav283283.jpg"
$thumbFile = "E:\tempfiles\sav9696.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}


Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.