We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script repository

Export user photo to file

September 05, 2025 Views: 3058

The script exports a user's photo stored in the Picture (thumbnailPhoto) attribute to a file.

To export photos using Adaxes, you can create a custom command that runs the script. For more information, see Create a Custom Command.

Parameters:

  • $filePath - specifies a template for the file path that will contain the user's photo. You can use value references (e.g. %username%) to insert properties of the user account as a part of the path.

Edit Remove
PowerShell
$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
avatar
Daniel Sadler Jun 07, 2022
Does this pull the info/photo from Office 365?
avatar
Support Jun 07, 2022
Hello Daniel,

No, the script gets the photo from the Picture (LDAP name thumbnailPhoto) property of an on-premises AD account.
avatar
Keith Sep 05, 2025
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.
avatar
Support Sep 05, 2025
Hello Keith,

Thank you for pointing out the behavior. We updated the script accordingly.
Leave a comment
Loading...

Got questions?

Support Questions & Answers