Posted on 11-10-2016 11:45 AM
Hello,
I'm running into an odd issue that I can't seem to figure out. Since upgrading my image to MacOS Sierra, I can not get Location Services to turn on automatically during or after imaging. I've tried nearly every script and action that I could find on JamfNation, and nothing seems to work.
Does anyone have a method to enable location services? I need to get this enabled so that the time on the machines will be correct. I have been able to set the time manually and with a script to a certain time zone, however we ship our macs to many different time zones for our employees after they are imaged. Would be great to have this set automatically based on location.
Thank you for any suggestions you may have.
Posted on 11-10-2016 11:57 AM
I'm currently using this, but have commented out the sections for "#Set an initial time zone" and "#Set specific time server", as these are being set elsewhere. https://www.jamf.com/jamf-nation/discussions/13723/enabling-location-services-programmatically-via-c...
Posted on 11-10-2016 12:41 PM
@kish.jayson Do you happen to be on Sierra?
I tried that script before posting, and once more with parts of it commented out after reading your comment. It still doesn't seem to be enabling location services.
Posted on 11-10-2016 12:43 PM
I am. Tested on both macOS Sierra and OS X El Capitan.
Posted on 11-10-2016 03:40 PM
Just out of curiosity, did you reboot the system after running the script? If not, try that and check again. I had a couple of occasions where simply re-loading the LaunchDaemon wasn't enough.
Posted on 11-12-2016 02:54 AM
Location Services on 10.12 falls some under SIP, which is most likely why you're seeing this.
Posted on 12-16-2016 05:53 AM
Has anyone resolved this? We have just started testing with Sierra and had a script that was working with Yosemite & El Cap; it no longer is, nor do the commands listed in the script that was linked above.
Anyone enabling Location Services before/after imaging in Sierra and how are they doing it?
Posted on 12-16-2016 06:36 AM
@MTurnerFMRCO I still haven't found a solution to this issue.
Posted on 12-20-2016 07:51 AM
WOuld be interested in solution as well. Have tried many different scripts with no luck yet. I am on Sierra.
Posted on 01-05-2017 07:59 AM
Found another post which seems to be working in 12.2.2.
Enabling Location Services Programmatically via Casper
Specifically this piece of the post from @ssrussell
#!/bin/bash
## Unload locationd
launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
## Write enabled value to locationd plist
defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
## Fix Permissions for the locationd folder
chown -R _locationd:_locationd /var/db/locationd
## Reload locationd
launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
exit 0
So far, this has been working when ran manually or during imaging after reboot.
Posted on 01-18-2017 11:47 AM
This script worked perfectly in our environment for 10.12.2!
Thank you @MTurnerFMRCO and @ssrussell for sharing.
Posted on 01-18-2017 12:38 PM
@MTurnerFMRCO This worked for me! Thank you and @ssrussell !
Posted on 01-24-2017 01:49 PM
I have a mix of El Cap and Sierra devices, so I wrote this little beast, to cover them all:
#!/bin/bash
## Unload locationd
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
## Get the version of Mac OS
OS_Version=$(sw_vers -productVersion)
if [[ $OS_Version == 10.11* ]] ; then
## Write enabled value to plist (El Cap)
uuid=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57)
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd."$uuid" LocationServicesEnabled -int 1
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.notbackedup."$uuid" LocationServicesEnabled -int 1
elif [[ $OS_Version == 10.12* ]] ; then
## Write enabled value to locationd plist (Sierra)
defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
fi ## If OS is not 10.11 or 10.12, do nothing
## Fix Permissions for the locationd folder
/usr/sbin/chown -R _locationd:_locationd /var/db/locationd
## Reload locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
exit 0
My devices still need a reboot to get it to work, but that does make it work.
Posted on 07-25-2017 10:27 AM
Thanks @JayDuff, your script came in handy today
Posted on 07-25-2017 10:31 AM
I was having some trouble getting this to work reliably on 10.12.5 and 10.12.6 because of System Integrity Protection, so I reached out to AppleCare Enterprise Support. While not officially supported, the officially unsupported method is below.
sudo defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
sudo chown -R _locationd:_locationd /var/db/locationd
Posted on 10-20-2017 07:38 AM
@JayDuff Thanks for sharing your script, Jay. I was working with it in a different manner on yesterday and figured out a pretty slick way to package the script to enable location services in system preferences/security & privacy/privacy so that its a sure-fire hit everytime.
In composer...
Select “new”
In the left-hand column select: User Environment “Global Preferences”
This will create the necessary plist “.GlobalPreferences.plist” and seat it under:
/Users/administrator/Library/Preferences/…
You will also notice a second plist under preferences “com.apple.driver.AppleHIDMouse.plist” (which is the action that executes the enabling of the location services feature)
Click the down arrow under the newly created Global Preferences pkg and right click on the scripts folder.
Now, add a “postinstall” script template and insert the following:
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
OS_Version=$(sw_vers -productVersion)
if [[ $OS_Version == 10.11 ]] ; then
## Write enabled value to plist (El Cap)
uuid=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57)
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd."$uuid" LocationServicesEnabled -int 1
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.notbackedup."$uuid" LocationServicesEnabled -int 1
elif [[ $OS_Version == 10.12 ]] ; then
## Write enabled value to locationd plist (Sierra)
defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
fi ## If OS is not 10.11 or 10.12, do nothing
/usr/sbin/chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
exit 0
Lastly...
Add the script to the postinstall script template and build as a PKG
You should now have a package that you can drop into Casper Admin
Hope this helps also.
Posted on 11-09-2017 09:57 AM
Thanks for sharing your scripts - I doesn't seem to work with High Sierra if SIP is enabled:
If I'm trying to unload the locationd.plist /bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
I'm getting this message:
/System/Library/LaunchDaemons/com.apple.locationd.plist: Operation not permitted while System Integrity Protection is engaged
Do you experience the same issue here?
Best regards :)
Posted on 02-14-2018 04:41 AM
Jamf hasn't been able to provide a fix for only showing Location Service (After User Registration).
I did also enable Siri now and can see Location Service now.
Hope this will help you all.
Posted on 10-26-2018 11:13 AM
You shouldn't need to unload any launch daemons?
See last posts: https://www.jamf.com/jamf-nation/discussions/13723/enabling-location-services-programmatically-via-c...
Posted on 10-26-2018 11:59 AM
This works for me in High Sierra + Mojave
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
Posted on 03-03-2020 12:41 PM
I am looking for a way to do this in Catalina.