Do all the admin accounts have the same picture? If so, you could first run the following to get the path of the account picture:
dscl . -read /Users/admin Picture
Which will return (for example):
Picture:
/Library/User Pictures/Sports/Soccer.tif
using your cat.tif example as the new picture, you can then run:
sudo dscl . -change /Users/admin Picture '/Library/User Pictures/Sports/Soccer.tif' '/Library/User Pictures/Animals/Cat.tif'
Where the first argument after Picture is the path to the current picture and the second argument the path to the new picture. Then, as long as the image is on all the computers, you could push out that command via a script or policy.
At least, I think it should work.
I posted an answer for your response yesterday on the other thread you commented on:
https://jamfnation.jamfsoftware.com/discussion.html?id=3206
hi, thanks for the help.
i want to change the admin account profile pictures of some computer. I'll just have all the pictures I need on my master to do that. but do i need to do this command from an admin ? the users will be logged in on my active directory...
the script below deleted the picture but did not put the new picture. does it work with .jpg or .tiff ou .jpeg ?
thanks a lot !
I answered your question on the other thread about why you were unable to get your picture to work. It had to do with you not running the script using "sudo" since you were running from the terminal.
As to your post here, I have a package that I push to machines from Casper. That package drops the user picture into /Library/User Pictures/Integer. I can target that at specific machines if I want to. After installing that package, then I run the commands to change the picture for the admin user. And again, I do that with a script pushed from Casper, so the script runs as root. If you want to run it from the terminal by hand, you have to use sudo.
HTH
We'll talk here :)
Thanks !
The thing is even doing that it does not work, and even as root...
with a jpg it doesn't work either... and do I need to reboot or logout to see the changes . the images is deleted, i see the blue apple logo but not mine! and if I select an image from the macs users library it still doesn't work :(
how do you create this script to be run as root and create a policy if possible ?
thanks for your help
Okay, first up, why it isn't working (from the other thread). If you look at the last line of the commands:
sudo dscl . create /Users/admin Picture "/wunderman.tif"
You are telling dscl to use the image at the root of your hard drive ("/wunderman.tif"). If you want to use the image from the User Pictures folder that you placed there, the final command should look like this:
sudo dscl . create /Users/admin Picture "/Library/User Pictures/wunderman.tif"
Try that.
To your other question:
how do you create this script to be run as root and create a policy if possible ?
You would put the commands into a shell script file and upload that file to Casper via Casper Admin. Set the script to run as an At Reboot script (if you are wanting to do this during imaging, or as an After script if you want to run at any time. If all you want to do is change the picture, your script can be as simple as:
#!/bin/sh
dscl . delete /Users/admin jpegphoto
dscl . delete /Users/admin Picture
dscl . create /Users/admin Picture "/Library/User Pictures/wunderman.tif"
exit 0
Once uploaded to Casper, in the JSS you would create a policy and choose the script to run. If you need assistance creating the policy, refer to page 321 in the Casper Suite 8.5 Administrator's Guide.
And, to get better at scripting, I would highly suggest, as many others would, picking up a copy of O'Reilly's "Learning the Bash Shell" book:
http://www.amazon.com/Learning-bash-Shell-Programming-Nutshell/dp/0596009658/ref=sr_1_1?ie=UTF8&qid=1335967900&sr=8-1
Or there are plenty of other resources on the web for learning Bash.
HTH
hi,
My script WORKS !
thanks a lot,
now I'll try to get the images of my AD users from a file server in my script,
i'll let you know if I get it to work,
thanks again
Can you post the contents of your script?
This has all been very helpful. I'm beginning to get to the root of our problem. Our issue is we would like to reset the account picture on a particular group of computers.
We have tried the following commands as root through ARD and locally, everything appears to work, but we don't actually see the changes made, even after reboot
sudo dscl . -append '/Users/d46student' Picture '/Library/User Pictures/Fun/Gingerbread Man.tif'
sudo dscl . -change /Users/d46student Picture '/Library/User Pictures/Nature/Earth.tif' '/Library/User Pictures/Fun/Gingerbread Man.tif'
If it makes any difference, the computers are all on 10.7.5
anyone got a script that works for this please? Not working 10.8.4
Just for fun, started going over this stuff...
So the dscl command does seem to pull & add "legitimate" values...but that's not what the user picture is being derived from, at least not initially.
According to dscl, mine was "Smack.tif" (which I have not been seeing...not sure WHEN that was set!) - my login picture, however, was the lightning bolts. (These are all standard Apple choices, not stuff I've added). So, I changed it in System Preferences -> Users to the jazz guitar image...and the dscl key was suddenly gone...
Then, I used dscl to set it to Ying Yang.tif - the key took, but the picture did not change. I even switched to the login window & back, but it still had the jazz guitar image. hmm...
Next, I did some research & found that "recent" pictures are being stored in ~/Library/Containers/com.apple.ImageKit.RecentPictureService/Data/Library/Images/Recent Pictures - looking here, I found a bunch of cryptic file names, such as A3D57D81-59FA-442F-A1F6-CA0405D09DE8-thumbnail.tiff - which turned out to be the jazz guitar picture! Right below that one was the lightning bolts - aha! I confirmed this by running 'open *" in Terminal, which of course opened every file in the directory. I did not see the Ying Yang.tif, however...until...
I went back to System Preferences/Users to change pictures again...and suddenly I have Ying Yang as my profile picture. =8-0
So anyway...there's something else going on here besides dscl alone.
Continued...
Changed the picture a couple more times using dscl - and the picture updates by going to the login window and back. However, opening up System Preferences -> Users & Groups again, the Ying Yang is still there. If I change it here, the dscl key is deleted and the picture updates immediately, i.e. no login window round-trip needed.
And again, setting a picture via dscl again has no immediate effect...and I can't seem to get it to update again, no idea how that happened the last time?
Very strange...
Hi all,
I've been trying to do this for some time...
From what I've been noticing, seems that the absolute path of the Picture in the user's plist has been replaced to a HEX value.
So, if I run in Terminal
dscl . -read /Users/me Picture
Terminal kicks back
No such Key
but if i do
dscl . -read /Users/me jpegphoto
Terminal kicks back
the HEX of the photo
I changed from within System Pref the photo from the built in Butterfly to the Baseball and sure enough, the hex changes.
Compared the HEX output using HexEdit.app and sure enough I was right.
So I think it's a matter of converting the photo that you want to use into HEX and then replacing the
jpegphoto
Key in the targeted plist.
But I'm afraid of HEX
:)
I can't take credit for coming up with this, but I've used it successfully in the past to convert the hex to a jpeg:
dscl . -read /Users/username JPEGPhoto | tail -1 | xxd -r -p > /path/to/save/whatever.jpg
Just checking to see if anyone has this working on 10.9?
Unfortunately, dscl cannot write binary values, so there is no way to set a picture using it. dsimport can, so:
#!/bin/bash
echo "0x0A 0x5C 0x3A 0x2C dsRecTypeStandard:Users 4 dsAttrTypeStandard:RecordName dsAttrTypeStandard:UniqueID dsAttrTypeStandard:GeneratedUID externalbinary:dsAttrTypeStandard:JPEGPhoto" > import.txt
echo $USER:$UID:$(id -g):$(dscl . -read /Users/$USER GeneratedUID | cut -d' ' -f2):/path/to/user_picture.jpg >> import.txt
dscl . -delete /Users/$USER JPEGPhoto
dsimport /path/to/import.txt /Local/Default M -u diradmin
rm import.txt
The script creates a file formatted for dsimport based on existing account data and with a pointer to a user picture, which must be in JPEG format, and then deletes the existing user picture, if any, and merges the import file with the existing account. dsimport handles encoding the JPEG and copying it into the account record.
I just tested this on my machine running 10.9, and I'm still able to use my original method of changing the user icon:
#!/bin/sh
dscl . delete /Users/admin jpegphoto
dscl . delete /Users/admin Picture
dscl . create /Users/admin Picture "/Library/User Pictures/wunderman.tif"
exit 0
If you want to use a different picture, just make sure the picture is on the system and point that last dscl line to that location.
Hey all. Thought I'd contribute to this thread since I figured out how to do this.
# # Reboot is highly encouraged # #
#!/bin/bash
# Delete the hex entry for jpegphoto
dscl . delete /Users/USER jpegphoto
dscl . delete /Users/USER Picture
dscl . create /Users/USER Picture "/Library/User Pictures/Fun/Chalk.tif"
# This forces the system to rebuild the system caches
#+ along with the local directory cache.
kextcache -system-caches
exit
This is known to work on 10.8 and 10.9. I haven't tested it on 10.7.
anyone had any luck on 10.10.2?
Can't seem to get this working on the filevault 2 screen
Thanks
I've got the same issue with @tkimpton. This works great for getting the icon set everywhere except for the FileVault 2 login screen.
The only way I've been able to get it set there is by going to System Preferences, changing the icon to something else, then changing it back. It's got to be doing something else when setting the user icon in System Preferences, but what?
It's rebuilding a bunch of files used in the EFI pre-boot environment.
When FileVault 2 is active and you power on the machine, when you see the screen that shows user icons: the machine is NOT RUNNING OS X at that point. The boot volume is still encrypted! The machine is running the EFI boot loader.
You can get OS X to rebuild the files used by EFI to display the user picture, etc like so:
sudo touch /System/Library/PrivateFrameworks/EFILogin.framework/Resources/EFIResourceBuilder.bundle/Contents/Resources
It's an odd thing; one would expect an actual command to run, but it seems to work.
unfortunately this still doesn't work on fv2 screen on 10.10.2
has anyone got this working please?
has anyone got this to work on 10.12? All I can manage to do is end up with this situation
@quedayone thanks for finding that! I just tested that and it works!