Script repository
The script imports a user photo into Active Directory from a file. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.
In the script, the $picturePath variable specifies the full path to the image file.
$picturePath = "\\SERVER\Share\%username%.jpg" # TODO: modify me
# Check whether the picture file exists.
if(!(Test-Path -Path $picturePath))
{
$Context.LogMessage("File does not exist '$picturePath'.", "Error")
return
}
# Save picture to AD.
[Byte[]]$pictureBytes = [System.IO.File]::ReadAllBytes($picturePath)
$Context.TargetObject.Put("thumbnailPhoto", $pictureBytes)
$Context.TargetObject.SetInfo()
Comments 0
You must be signed in to comment.