Skip to main content
Question

Extension to report the state of Location Services and location services

  • August 27, 2026
  • 2 replies
  • 28 views

Forum|alt.badge.img+4

I am looking to report the status of Location Services on our fleet.  I found the following script online and tested it but it only reports back disabled even when LS is enabled.   Does anyone have a working extension for this?  Or can some assist in making this one work?
 

#!/bin/bash

uuid=$(system_profiler SPHardwareDataType | grep "Hardware UUID" | awk '{print $3}')
domain="/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.${uuid}"
plist="${domain}.plist"

if [[ -f "${plist}" ]]
then
    status=$(defaults read "${domain}" LocationServicesEnabled)
    if [[ "${status}" == "1" ]]
    then
        result="Enabled"
    else
        result="Disabled"
    fi
else
    result="Unavailable"
fi

echo "<result>${result}</result>"

2 replies

mattjerome
Forum|alt.badge.img+13
  • Jamf Heroes
  • August 27, 2026

here’s what I use

 

#!/bin/bash

locationServices=$(sudo defaults read /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled)
if [[ "$locationServices" == "1" ]]; then
    echo "<result>True</result>"
else
    echo "<result>False</result>"
fi


thebrucecarter
Forum|alt.badge.img+16

Hey Matt,

Caveat this (and anything else I say today) with the fact that I am ill and running a lovely fever, but if you’re using this as an EA from Jamf, do you actually need the sudo in there?  I just saved this out and ran it as a script in Terminal just to see it go, and noticed it prompted me for a password for the sudo, which, of course, it would in that case.