Import thumbnailphoto in AD from jpg

The script below will import Jpg file as a thumbnail photo in Active Directory

$username = "p01001"
$jpgfile = "C:\PICTURE.jpg"

$dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$root = $dom.GetDirectoryEntry()
$search = [System.DirectoryServices.DirectorySearcher]$root
$search.Filter = "(&(objectclass=user)(objectcategory=person)(samAccountName=$username))"
$result = $search.FindOne()
if ($result -ne $null) {
 $user = $result.GetDirectoryEntry()
 [byte[]]$jpg = Get-Content $jpgfile -encoding byte
 $user.put("thumbnailPhoto",  $jpg )
 Write-Host $user.displayname "updated"
}celse {
  Write-Host $user "Does not exist"


Fix – FRS Event 13508

To fix the problem, you need to designate a domain controller to be authoritative for the Sysvol replica set.

1. Stop the File Replication service on the PDC emulator FSMO role holder.
2. Use the Registry Editor to navigate to:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NtFrs\Paramaters\Backup\RestoreProcess at Startup.

3. Double-click the BurFlags Value Name, a REG_DWORD data type, and set the data value to D4, using the Hex radix.
4. Exit the Registry Editor.
5. Start the File Replication service.

Note: If the BurFlags Value Name is set to D4 (authoritative) on more that one replica, conflicts and collisions will occur.