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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s