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.
Set user images in Active Directory with PowerShell
May 21, 2017
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}
You May Also Like