Posted on 04-27-2018 03:39 PM
None of the solutions that I've found work anymore in 10.12 (Sierra) or above.
Most solutions are something like this:
#!/bin/sh
dscl . delete /Users/admin jpegphoto
dscl . delete /Users/admin Picture
dscl . create /Users/admin Picture "/Library/User Pictures/wunderman.tif"
exit 0
But I think that parts of this are deprecated.
Even the ones that somewhat work result in things like this:
I used this thread and tried all of the solutions there: [https://www.jamf.com/jamf-nation/discussions/4332/how-to-change-local-user-account-picture-through-command-terminal](link URL)
The only thing that comes close is from the final post by @tech-otaku . So I've got my script, and it executes locally perfectly fine.
It would appear as though the issue is that when executed via a JAMF policy it doesn't have a password to use (and we can't put our passwords in our scripts), nor does it even prompt for one (see following snippet for where I think the problem is).
#Imports profile picture from import.txt
dsimport /Users/<ADMIN>/Documents/import.txt /Local/Default M -u <ADMIN>
No idea how to get around that.
Here's the full script:
#!/bin/bash
#Creates import.txt in <ADMIN>'s Documents folder
echo "0x0A 0x5C 0x3A 0x2C dsRecTypeStandard:Users 5 dsAttrTypeStandard:RecordName dsAttrTypeStandard:UniqueID dsAttrTypeStandard:PrimaryGroupID dsAttrTypeStandard:GeneratedUID externalbinary:dsAttrTypeStandard:JPEGPhoto" > /Users/<ADMIN>/Documents/import.txt
#Finds current user GUID, specifies which profile picture to use and writes to import.txt
echo $USER:$UID:$(id -g):$(dscl . -read /Users/$USER GeneratedUID | cut -d' ' -f2):/Library/User Pictures/Nature/Cactus.tif >> /Users/<ADMIN>/Documents/import.txt
#Deletes previous profile picture
dscl . -delete /Users/<ADMIN> JPEGPhoto
#Imports profile picture from import.txt
dsimport /Users/<ADMIN>/Documents/import.txt /Local/Default M -u <ADMIN>
#Deletes import.txt from Documents folder
rm /Users/<ADMIN>/Documents/import.txt
exit 0
<ADMIN> is not the real account I'm trying to modify.
Thanks for your help.