0 votes

Hello,

Could you help me with a script to save the picture attribute from a targeted user to a temporary jpg file named employeeid.jpg, and then move that jpg to a network file share?

Thanks so much!
Ryan

by (920 points)
0

Hello Ryan,

Yes, sure. We'll update you as soon as it is ready.

1 Answer

0 votes
by (216k points)
selected by
Best answer

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:

  1. Create a new Custom Command.
  2. On the 2nd step of the Create Custom Command wizard, select the User object type.
  3. On the 3rd step, add the Run a program or PowerShell script action and paste the above script in the Script field.
0

Thank you so much! Works like a charm!

Related questions

0 votes
1 answer

I'm trying to do something very similar to: https://www.adaxes.com/questions/10758/copy-image-uploaded-binary-custom-attribute-network-share but rather than uploading the M365, uploading to ... it, but I'm stuck on this step. I have Adaxes version 3.16.21627.0

asked Oct 28 by jmatthews (190 points)
0 votes
1 answer

I'm wondering if there is anyway to allow for re-sizing of a user picture? For example, a new employee starts and HR takes their photo on a digital camera, resulting ... great if it could all happen in the background once they select it in Adaxes. Thanks Ryan

asked Mar 6, 2014 by ryan_breneman (920 points)
0 votes
1 answer

My HR deparment has the ability to export users with managers report to Excel, however the user's picture in embeded into the name column and there is no way to remove it from the report nor from the Excel exported file. Please help.

asked Aug 29 by jurbina (40 points)
0 votes
1 answer

Is it possible to configure a home page action to change the Picture attribute? Currently, if you put the property in a form, a text box is displayed. Is there a way to duplicate the UI of the set photo dropdown?

asked Feb 23, 2015 by polley (1.2k points)
0 votes
1 answer

Is there a way for Adaxes to use a user's Microsoft 365 profile pictures instead of having to select a file on a per user basis?

asked Feb 1 by keneth.figueroa (20 points)
3,549 questions
3,240 answers
8,232 comments
547,814 users