Hello Ryan,
The script is ready. Since the PowerShell cmdlet Set-Content allows saving files to network shares, there's no need for a temporary file. The output file will be created on the network share right away. The template for the file path is specified by $filePath.
$filePath = "\\Server\share\UserPictures\%username%.jpg" # TODO: modify me
try
{
$thumbnailPhoto = $Context.TargetObject.Get("thumbnailPhoto")
}
catch
{
# The Picture property is empty
$Context.LogMessage("The selected user doesn't have a photo.", "Information")
return
}
# Write the photo to a file
try
{
Set-Content -Path $filePath -Encoding byte -Value $thumbnailPhoto -ErrorAction Stop
}
catch
{
$Context.LogMessage($_.Exception.Message, "Error")
}
To be able to use the script in Adaxes, you can, for example, create a Custom Command that can be executed on user to save the photo of that user. To create such a Custom Command:
- Create a new Custom Command.
- On the 2nd step of the Create Custom Command wizard, select the User object type.
- On the 3rd step, add the Run a program or PowerShell script action and paste the above script in the Script field.