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}
0 comments
Hide comments