Posted on 12-09-2020 05:10 PM
I am banging my head against the wall with this one and I feel a though the solution should be simple. I read that Jamf Pro 10.26 is supposed to be able to permit enabling NTP/time zone settings without needing location services turned on. However, for the life of me, I cannot find documentation detailing how. I tested a custom configuration profile that does apply the settings successfully, but only if location settings are enabled. For Catalina, I currently use a script (see below). I do not want to rely on my end users turning on location settings to get this configured.
How is everyone else doing this now? Am I missing something obvious?
Current script:
#!/bin/sh
####################################################################################################
#
# DEFINE VARIABLES/PARAMETERS
#
####################################################################################################
timeserver="$4"
defaults='/usr/bin/defaults'
systemsetup='/usr/sbin/systemsetup'
uuid=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57)
####################################################################################################
#
# SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################
# Configure automatic timezone
"$defaults" write /Library/Preferences/com.apple.timezone.auto Active -bool YES
"$defaults" write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeOnlyEnabled -bool YES
"$defaults" write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeZoneEnabled -bool YES
# Configure network time server settings
"$systemsetup" -setnetworktimeserver $timeserver
"$systemsetup" -setusingnetworktime on
# Configure location services
"$defaults" write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
"$defaults" write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1
Solved! Go to Solution.
Posted on 12-10-2020 10:52 AM
I don't get it. In my environments the user enrols his device and not any technicians. You can easily turn o/off location service with a simple command:
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
It just needs a restart. That is something you can completely automate without any user interaction.
Posted on 12-10-2020 02:06 AM
Why not turning location service on, then set the correct time zone and time and afterwards you can turn it off again?!
Posted on 12-10-2020 05:13 AM
Just to confirm, you set them using these keys?
Posted on 12-10-2020 09:14 AM
@slang , my technicians do not always provision devices. More often, we send devices to the end user. I don't want to rely on end users turning location services on and then off. That introduces an unnecessary variable to a critical configuration component that's outside of my ability control as it is happening. That will just generate more support tickets.
Posted on 12-10-2020 09:45 AM
@psliequ , yes. Here's the relevant, redacted portion of the config profile.
<dict>
<key>PayloadDescription</key>
<string>Configures Time Server settings</string>
<key>PayloadDisplayName</key>
<string>Time Server</string>
<key>PayloadIdentifier</key>
<string>REDACTED</string>
<key>PayloadOrganization</key>
<string></string>
<key>**PayloadType**</key>
<string>**com.apple.MCX**</string>
<key>PayloadUUID</key>
<string>REDACTED</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>**timeServer**</key>
<string>timeserver.goes.here</string>
<key>**timeZone**</key>
<string>/usr/share/zoneinfo/America/New_York</string>
</dict>
So like I said, this actually works as long as we turn on location services. However, I want to be able to control this without turning on location services (or have the ability to turn on location services programmatically). It would mean we have to have a technician onsite (currently remote) to receive devices, step through setup to turn on location services, and then box the devices and send the device to the user instead of shipping directly to users. That adds time (impacting SLAs) and shipping costs—no bueno. This should be elementary so I feel as though I am missing something that is quite obvious to everyone else. Any help is appreciated. Thanks.
Here's the link that led me to believe this is possible: https://www.jamf.com/blog/macos-big-sur-same-day-support/
The specific mention reads, "This new operating system also includes key updates to MDM commands and restrictions, including the ability to set a default time zone and restrict Wi-Fi MAC address randomization."
Posted on 12-10-2020 10:52 AM
I don't get it. In my environments the user enrols his device and not any technicians. You can easily turn o/off location service with a simple command:
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
It just needs a restart. That is something you can completely automate without any user interaction.
Posted on 12-10-2020 11:28 AM
@slang , is this working in Catalina or Big Sur? That works for me in Catalina but not in Big Sur. See above for my script for Catalina. I have that line in there and it's working fine. But like I said, it's no bueno in Big Sur.
Posted on 12-10-2020 11:36 AM
@slang Edit: Disregard this. The reboot made the difference. Thanks.
Posted on 03-01-2021 10:56 AM
looks like this needs to flush the cached preferences, had a user on Catalina just test this for me and the time zone didn't change immediately after the reboot, but about 10 minutes later.
Thoughts on what to killall to force the change (and perhaps eliminate the reboot)
Posted on 03-01-2021 11:07 AM
mcxrefresh
This may do the trick. You may need the -a option. I dunno.
Posted on 06-11-2021 11:14 AM
ive always used the JAMF provided scripts for SetTimeZone and SetTimeServer and it looks like both scripts were updated in 12/2021 so it should work for Big Sur.
Gonna test it out
Tested out both the updated V3.0 settimezone & settimeservers on Big Sur and it worked.
Posted on 07-20-2021 04:07 AM
@tcandela Can you share a link to the JAMF provided scripts you mentioned? (SetTimeZone and SetTimeServer)
Posted on 07-27-2021 01:31 PM
JAMF keeps changing the user interface and i can't find the section where they have the scripts.
I'm gonna try looking again.
Posted on 08-02-2021 02:10 AM
@tcandela Any luck with this?
Posted on 08-02-2021 02:49 PM
08-02-2021 02:49 PM - edited 08-02-2021 02:50 PM
no luck. since the GUI changes JAMF has made i can't find the 'scripts' section.
horrible GUI changes
Posted on 09-13-2021 07:23 PM
https://github.com/jamf/Jamf-Nation-Scripts/blob/175bbaa10af79f0aca6cb5e06eb8af130a6e3e8a/setTimeZon...
The above script still works, just had to comment out line #126 to #132
Since we have users from different timezones, i use ip-api to set timezone based on their current location by adding simple 2-liner command below.
Add it as a self service policy and users can fix this without needing temp admin access.
myIP=$(curl -L -s --max-time 10 http://checkip.dyndns.org | egrep -o -m 1 '([[:digit:]]{1,3}.){3}[[:digit:]]{1,3}')
timeZone=$(curl -L -s --max-time 10 "http://ip-api.com/line/$myIP?fields=timezone")
Posted on 01-11-2022 03:15 PM
Hi,
Can anyone help me to provide the latest "SetTimeZone and SetTimeServer" Jamf script? as their old scripts are not working in M1+Monterey OS. Scripts are executing without any error but Time Zone>>"Set time zone automatically using current location" tick is not not enabled.
Posted on 01-12-2022 10:53 AM
I use the script below. It does toss an error in CLI on AppleSilicon but still changes the time zone and time server. The error looks to be related to 911 stuff but I have not dug in to it.
$4 is used for the time zone for example Chicago/America which I put in the policy to only need one script.
$5 is for the time server you want to use, we have to use an internal time server. This can be removed.
#!/bin/sh
####
# Script Name: Set Time Zone
# Author:
# Date:
# Purpos: Set time zone for Macs
# Notes:
####
#--------------------------------------------------------
# Set the Mac timezone & timeservers
#--------------------------------------------------------
# Set the timezone
systemsetup -settimezone "$4"
# Set the timezone to regions internal time server
/usr/sbin/systemsetup -setnetworktimeserver "$5"
# The below command will list all available timezones
# systemsetup -listtimezones