- The files must have names that corresponds to unique user attributes such as SamAccountName
- The files must not exceed 10kb in size
- The dimensions of the pictures should be the recommended 96x96 pixels but this isn't required
- All files must be JPEG images (*.jpg)
Once the folder with above mentioned prerequisites have been established, the following script imports them to the Active Directory.
Path = 'C:\Temp\ImportThumbnails\Photos'
import-module ActiveDirectory
ForEach ($File in Get-ChildItem $Path | Where-Object { $_.Extension -eq ".jpg" } )
{
$UserName = $File.Name.substring(0, $File.Name.Length - 4)
Write-Host $UserName -NoNewLine
$Photo = [byte[]](Get-Content -Path $File.Fullname -Encoding byte)
Set-ADUser $UserName -Replace @{thumbnailPhoto=$Photo}
Write-Host " [Done]" -ForeGroundColor Green
}
Don't forget to make sure that the thumbnailPhoto attribute is replicated to the Global Catalog in the Active Directory Schema.
No comments:
Post a Comment