Script runs locally but not through Jamf

New Contributor III

If I open Terminal and run this command it works fine. In System Preferences...General it changes "Show scroll bars" to Always
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"

I put this into a script in Jamf and attach it to a policy and it will not work. The policy definitely runs but the change is not made to the scroll bars


defaults write NSGlobalDomain AppleShowScrollBars -string "Always"

Any ideas?


Contributor III

When run using Jamf it is run as root. Try:


consoleuser=$(ls -l /dev/console | cut -d " " -f4)

su - "${consoleuser}" -c 'defaults write NSGlobalDomain AppleShowScrollBars -string "Always"'

exit 0

Contributor II

When running via jamf scripts run as root. When you run them in terminal they are running with the user you signed in as. So you need to loop through all the user home directories and run the command against their .GlobalPreferences file then ensure you have corrected the permissions back to the proper owner. But thats if you want the change to apply to all users. Alternatively just get the console username and run the


_user=`who | grep console | awk '{ print $1 }'`
sudo -u $_user defaults write /Users/$_user/Library/Preferences/.GlobalPreferences AppleShowScrollBars -string "Always"

You may be able to put this in the /Library/Preferences/.GlobalPreferences.plist, not sure that will work.

New Contributor III

One of the harder things to do on the Mac (PC as well) is trying to decide if a change to a setting/preference is going to affect all users or just the user logged in. For example, if I shrink the size of the Dock logged in as myself and someone else logs in, will the Dock be shrunk for them (it won't be). If I put in an ntp server in the Date & Time System Preference it is a computer setting (affects all users). Even when I look at a statement like this below it is not obvious whether it is a user level change
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"

If I want everyone who logs into a Mac the first time to get a change in their scroll bar, would one of the methods provided do the trick? I am guessing this will also involve the scope settings for this script as well.