Recently I was tasked to add photos to user accounts in AD. Manually doing hundreds of users is not an option so powershell to the rescue.

This scripts looks at a path and directory, you can change the path and directory to suite your requirements. It goes and imports all photos for all users.

Make sure you have the same name as the user stored in Active Directory or the import will fail.

Here is the script:

$PicturePath = “D:Pictures*.*”
ForEach ($PhotoFile in gci $PicturePath)
$User = ” + $PhotoFile.Name.substring(0, $PhotoFile.Name.Length – 4) + ”
Import-RecipientDataProperty -Identity $User -Picture -FileData ([Byte[]]$(Get-Content -Path $PhotoFile.Fullname -Encoding Byte -ReadCount 0))

I also posted this on Technet. It includes 2 other scripts for allowing you to remove a picture from a users account or add a picture to an individual AD User.

Hope it helps.

Discover more from COLLABORATION PRO

Subscribe now to keep reading and get access to the full archive.

Continue reading