Posted on 06-05-2017 11:55 AM
I'm running the following script as a part of a Microsoft Office deployment.
#!/bin/sh
/bin/sleep 1
/Library/Application Support/JAMF/bin/dockutil --add '/Applications/Microsoft Excel.app' --replacing 'Microsoft Excel'
/bin/sleep 5
/Library/Application Support/JAMF/bin/dockutil --add '/Applications/Microsoft Word.app' --replacing 'Microsoft Word'
/bin/sleep 5
/Library/Application Support/JAMF/bin/dockutil --add '/Applications/Microsoft PowerPoint.app' --replacing 'Microsoft PowerPoint'
/bin/sleep 5
/Library/Application Support/JAMF/bin/dockutil --add '/Applications/Microsoft OneNote.app'
killall -KILL Dock
exit 0
The install policy runs and returns Exit Code 0, but in the end the icons in the Dock have not changed.
So I created another policy that does nothing but run this script and set it to run at recurring check-in. Again the policy logs return Exit Code 0 but the icons have not changed.
However this is where things get really strange. If I flush the log for a device, then manually run jamf policy from Terminal it works as expected.
Has anyone else come across this before?
I'm running dockutil 2.0.5. Clients are Yosemite, El Cap and Sierra.
Post edited to correct jamf recon to jamf policy/
Solved! Go to Solution.
Posted on 06-05-2017 12:38 PM
Try this.. of course adjust as needed.. But this what I used to run and it worked pretty well on those OS's
#!/bin/sh
DOCKUTIL=/usr/local/bin/dockutil
$DOCKUTIL --remove all --no-restart /Users/$3
sleep 10
$DOCKUTIL --add '/Applications/Launchpad.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Safari.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Microsoft Outlook.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Microsoft Word.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Microsoft Excel.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Self Service.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Microsoft PowerPoint.app' --no-restart /Users/$3
killall cfprefsd
killall Dock
exit 0
Posted on 06-05-2017 12:38 PM
Try this.. of course adjust as needed.. But this what I used to run and it worked pretty well on those OS's
#!/bin/sh
DOCKUTIL=/usr/local/bin/dockutil
$DOCKUTIL --remove all --no-restart /Users/$3
sleep 10
$DOCKUTIL --add '/Applications/Launchpad.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Safari.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Microsoft Outlook.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Microsoft Word.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Microsoft Excel.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Self Service.app' --no-restart /Users/$3
$DOCKUTIL --add '/Applications/Microsoft PowerPoint.app' --no-restart /Users/$3
killall cfprefsd
killall Dock
exit 0
Posted on 06-05-2017 03:40 PM
That worked. Here's my script as I modified it.
For some reason when I set the variable
/Library/Application Support/JAMF/bin/dockutil
it would error with the invalid path
/Library/Application Support/JAMF/tmp/dockutil
So I just removed the variable and this worked.
#!/bin/sh
/bin/sleep 1
/Library/Application Support/JAMF/bin/dockutil --add '/Applications/Microsoft Excel.app' --replacing 'Microsoft Excel' --no-restart /Users/$3
/bin/sleep 2
/Library/Application Support/JAMF/bin/dockutil --add '/Applications/Microsoft Word.app' --replacing 'Microsoft Word' --no-restart /Users/$3
/bin/sleep 2
/Library/Application Support/JAMF/bin/dockutil --add '/Applications/Microsoft PowerPoint.app' --replacing 'Microsoft PowerPoint' --no-restart /Users/$3
/bin/sleep 2
/Library/Application Support/JAMF/bin/dockutil --add '/Applications/Microsoft OneNote.app' --no-restart /Users/$3
/bin/sleep 2
killall -KILL Dock
exit 0
Posted on 06-07-2017 10:45 AM
Awesome.. glad that worked for you
Posted on 06-25-2018 02:06 PM
Just jumping in for another report that the format provided by @gskibum works for me as well. Thanks for the help!
edit: Just spent about 2 hours beating my head against the wall trying to figure out why this worked sometimes and didn't other times. Turns out the script was running too fast and the items weren't getting written to the plist fast enough. I had to buffer each step with a 'sleep 1' like so — might be a cleaner way to do this, but it's been running reliably for me since the change.
#!/bin/sh
# mw 6-25-18
# Script to setup user Dock upon sign in
# Script tends to run too fast, so all steps are buffered with a 'sleep 1'
echo "==================================================================================" >> /var/log/jamf.log
echo "Setting up Dock for $3. Clearing default Dock..." >> /var/log/jamf.log
# Clearing Dock for currently signed in user
/usr/local/bin/dockutil --remove all /Users/$3
sleep 1
# Adding Applications
echo "Adding apps to Dock for $3..." >> /var/log/jamf.log
/usr/local/bin/dockutil --add "/Applications/Dashboard.app" --after 'Finder' --no-restart /Users/$3
sleep 1
/usr/local/bin/dockutil --add "/Applications/Launchpad.app" --after 'Dashboard' --no-restart /Users/$3
sleep 1
/usr/local/bin/dockutil --add "/Applications/Google Chrome.app" --after 'Launchpad' --no-restart /Users/$3
sleep 1
/usr/local/bin/dockutil --add "/Applications/Slack.app" --after 'Google Chrome' --no-restart /Users/$3
sleep 1
/usr/local/bin/dockutil --add "/Applications/Notes.app" --after 'Slack' --no-restart /Users/$3
sleep 1
/usr/local/bin/dockutil --add "/Applications/App Store.app" --after 'Notes' --no-restart /Users/$3
sleep 1
/usr/local/bin/dockutil --add "/Applications/Self Service.app" --after 'App Store' --no-restart /Users/$3
sleep 1
/usr/local/bin/dockutil --add "/Applications/SonicWall Mobile Connect.app" --after 'Self Service' --no-restart /Users/$3
sleep 1
/usr/local/bin/dockutil --add "/Applications/System Preferences.app" --after 'SonicWall Mobile Connect' --no-restart /Users/$3
sleep 1
# Add SA standard folders
/usr/local/bin/dockutil --add "~/Documents/" --view grid --display folder --sort name --no-restart /Users/$3
sleep 1
/usr/local/bin/dockutil --add "~/Downloads/" --view fan --display folder --sort dateadded /Users/$3
sleep 1
echo `date "+%a %b %d %H:%M:%S"` " - $3 Dock setup complete!"
echo "==================================================================================" >> /var/log/jamf.log
exit 0