USER PICTURES IN AD
Function
Add-AdThumbnailPhoto { PARAM ( [ValidateScript({Test-Path $_ -PathType Leaf})] [string] $PicturePath, $UserAccount ) If (!(Test-IsModuleLoaded "ActiveDirectory")) { Throw "You need to run: Import-Module ActiveDirectory" } Write-Verbose "Adding $($PicturePath) to $($UserAccount)" $pictureBinary = [byte[]](Get-Content $PicturePath -Encoding byte) If ([System.Text.Encoding]::ASCII.GetString($pictureBinary).Length -ge 100Kb) { Throw "Picture to large, max size is 100Kb" } Try { Set-AdUser $UserAccount -Replace @{ thumbnailPhoto = $pictureBinary } } Catch { Throw $error[0] } } # one liner Add-AdThumbnailPhoto -PicturePath "C:\MyPicture.jpg" -UserAccount "MyUserAccount" # or Set-AdUser "MyUserAccount" -Replace @{ thumbnailPhoto = ([byte[]](Get-Content "C:\MyPicture.jpg" -Encoding byte) }
Spiceworks Link
https://community.spiceworks.com/scripts/show/3708-user-pictures-in-ad