Script repository
The script exports a user’s photo stored in the thumbnailPhoto property to a file. To execute the script, create a custom command, business rule or scheduled task configured for the User object type.
In the script, the $filePath variable specifies a template for the path to the file that will contain the photo. You can use value references, (e.g. %username%) in the path.
$filePath = "\\Server\share\UserPictures\%username%.jpg" # TODO: modify me
try
{
$thumbnailPhoto = $Context.TargetObject.Get("thumbnailPhoto")
}
catch
{
return # The Picture property is empty
}
try
{
Set-Content -Path $filePath -AsByteStream byte -Value $thumbnailPhoto -ErrorAction Stop
}
catch
{
$Context.LogMessage($_.Exception.Message, "Error")
}
Comments 4
You must be signed in to comment.
Daniel Sadler
Does this pull the info/photo from Office 365?
Support
Hello Daniel,
No, the script gets the photo from the Picture (LDAP name thumbnailPhoto) property of an on-premises AD account.
Keith
Just a note that this fails now that encoding a 'byte' has been deprecated as written.
Instead, just replace -Encoding 'byte' with -AsByteStream and it works great.
Support
Hello Keith,
Thank you for pointing out the behavior. We updated the script accordingly.