You may add/change photo in Active Directory using the following powershell.
Supply samAccountName and new Photo path. Script will look for existing photo in Active Directory, if exists compares and updates the new Photo. If no photo exists it adds Photo to Active Directory.
Supply samAccountName and new Photo path. Script will look for existing photo in Active Directory, if exists compares and updates the new Photo. If no photo exists it adds Photo to Active Directory.
Import-Module ActiveDirectory; $newPhoto = "c:\Path2NewPhoto\somePhoto.jpg"; $sourcePhoto = [byte[]](Get-Content $newPhoto -Encoding byte); $user = "samAccountName"; $fromAD = Get-ADUser $user -Properties thumbnailPhoto; $adTarget = "c:\Path2ADPhoto\photoFromAD.jpg"; if ($fromAD.thumbnailPhoto) {$fromAD.thumbnailphoto | Set-Content $adTarget -Encoding byte}; if (Test-Path $adTarget) { $adPhoto = [byte[]](Get-Content $adTarget -Encoding byte); if ((Compare-Object $adPhoto $sourcePhoto -SyncWindow 0) -eq $Null) { "Photo intact. No changes done"; } else { Set-ADUser $user -Replace @{thumbnailPhoto=$sourcePhoto}; "Photo Updated"; } } else { Set-ADUser $user -Add @{thumbnailPhoto=$sourcePhoto}; "New Photo Added"; }