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 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

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)
0 votes
1 answer

Hello, Similar to exporting the members of a group to a csv file: https://www.adaxes.com/script-repository/export-group-members-to-csv-file-s184.htm I am looking to ... would like to include the memberof csv report in the email as well. Thanks in advance!

asked Feb 7, 2023 by JonnyBGood (20 points)
0 votes
1 answer

I am using this script modified for my testing. Import-Module Adaxes $csvFilePath = "D:\TestFeed\ImportNewUsers.csv" # Path to pick up feed file $userIdColumn = "Employee Number" # TODO: ... initial. I would like to add a 2 for now if the sam isn't unique.

asked Oct 17, 2022 by mightycabal (1.0k points)
3,326 questions
3,026 answers
7,727 comments
544,681 users