@franton to be clear the only thing that would change would be the variable correct everything else would stay the same.
From:
uuid=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57)
To:
uuid=$( /usr/sbin/ioreg -d2 -c IOPlatformExpertDevice | awk -F" '/IOPlatformUUID/{print $(NF-1)}' )
@CorpIT_eB correct! that'd be the only change. (I just have this thing about not running system_profiler in scripts)
@sdagley Does this script require a reboot before it works?
@kericson I believe it does. I run this script with several others as part of my initial configuration process which ends in a restart to enable FileVault so I haven't tried it without rebooting.
@sateshb would you mind sharing how you read the value for location services? I'm trying to get an Extension Attribute so I can scope a smart group around it, but my scripting isn't good enough to grab that value.
#!/bin/bash
locationservices=(/usr/bin/defaults read /private/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled)
if [[ $locationservices = 1 ]]; then
result=Enabled
else
result=Disabled
fi
echo <result>$result</result>
Edit: Got it sorted, I missed the space after the '1' and the ']]'.
i get a "does not exist" even though location services is enabled and the timezone is set to auto on my machine, albeit manually.
im reading as i dont want to commit and am testing to see if it sees anything before i make changes, just i case i want to make an EA to scope things
C02YJ17VJHD4:~ ME$ /usr/bin/defaults read /private/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled
2020-01-08 12:14:37.504 defaults[88421:6521570]
The domain/default pair of (/private/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd, LocationServicesEnabled) does not exist
also this
C02YJ17VJHD4:~ ME$ /usr/bin/defaults read /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.2322ECE6-78B2-52A1-8F95-59C31793488A LocationServicesEnabled
2020-01-08 12:16:52.069 defaults[88432:6537060]
The domain/default pair of (/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.2322ECE6-78B2-52A1-8F95-59C31793488A, LocationServicesEnabled) does not exist
any suggestions?
EDIT:
it seems to be a permission issue.
tested by giving myself permission to the locationd to test and i got a "1" result.
removed access and it got the error.
ran same command with sudo and i get a result of "1"
will continue to test.
Jamf is running the command as root hence no sudo in anything else above.
Create a blank package with the script below. Then add it to your prestage enrollment.
#!/bin/bash
## configure ntp server
/bin/cat > /etc/ntp.conf << 'NEW_NTP_CONF'
server time.apple.com
NEW_NTP_CONF
## configure automatic timezone
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
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
## Set date and time automatically
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool YES
/usr/bin/defaults write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeOnlyEnabled -bool YES
/usr/bin/defaults write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeZoneEnabled -bool YES
/usr/sbin/systemsetup -setusingnetworktime on
/usr/sbin/systemsetup -gettimezone
/usr/sbin/systemsetup -getnetworktimeserver
### Restart location services daemon (locationd)
/usr/bin/killall locationd
exit 0; ## Success
exit 1; ## Failure
@bwoods Does this require a reboot to apply?
@KyleEricson No reboot required, it works immediately. Perfect for DEP/ADE deployments.