Bulk Import User Photos into Active Directory.

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.

http://gallery.technet.microsoft.com/Bulk-Import-User-Photo-9625d120

Hope it helps.

Views All Time
Views All Time
Views Today
Views Today
Advertisements

Leave a Reply

Your email address will not be published. Required fields are marked *