Script Repository


Export user photo to file

February 25, 2021
1780

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 -Encoding byte -Value $thumbnailPhoto -ErrorAction Stop
}
catch
{
    $Context.LogMessage($_.Exception.Message, "Error")
} 

Comments ( 0 )
No results found.
Leave a comment