Posted on 09-25-2021 07:13 AM
I couldn't find any extension attribute in the templates or in any forum for showing the local timezone of a computer in jamf, so I wrote my own.
It's just a simple script to pull the info from the localtime file, and cut off the first part that is always the same, then return the result to the jss.
example: /America/New_York
Script:
#!/bin/bash
# Extension attribute to return current TZ
localtime=`/bin/ls -n /etc/localtime`
TimeZone=${localtime:79}
echo "<result>$TimeZone</result>"
exit 0
Here's the full .XML file for importing to jamf directly:
<?xml version="1.0" encoding="UTF-8"?><extensionAttribute>
<displayName>TimeZone</displayName>
<description>gets time zone</description>
<dataType>string</dataType>
<scriptContentsMac>#!/bin/bash
# Extension attribute to return current TZ
localtime=`/bin/ls -n /etc/localtime`
TimeZone=${localtime:79}
echo "<result>$TimeZone</result>"
exit 0
</scriptContentsMac>
</extensionAttribute>
Feel free to use as needed!
Solved! Go to Solution.
04-19-2022 11:19 AM - edited 04-19-2022 11:20 AM
I changed this slightly to pipe this to awk
#!/bin/bash
# Extension attribute to return current TZ
localtime=`/bin/ls -n /etc/localtime | awk -F"zoneinfo/" '/zoneinfo/{print $2}'`
echo "<result>$localtime</result>"
exit 0
awk instead.
Posted on 09-27-2021 05:47 AM
The digital transformation consultant improves organization efficiency by implementing Enterprise software (ERP, CRM, HR, CX, HCM, business intelligence). We implement ERP solutions that enhance customer experience, improve efficiency and skyrocket growth. Our objective is to deliver ERP solutions that increase ROI and minimize risk. If You need ERP consultant then contact us.
09-27-2021 09:46 AM - edited 09-27-2021 09:51 AM
I was talking with my co-worker about this on Friday. Were you listening @user-dKGrgHyYDI like Alexa? 😁
Thx for the script
Posted on 01-28-2022 01:49 PM
Is there a way to get the specific time zone? (i.e. EST, PST)
Ideally going for a more generic grouping than specific locations.
04-19-2022 11:19 AM - edited 04-19-2022 11:20 AM
I changed this slightly to pipe this to awk
#!/bin/bash
# Extension attribute to return current TZ
localtime=`/bin/ls -n /etc/localtime | awk -F"zoneinfo/" '/zoneinfo/{print $2}'`
echo "<result>$localtime</result>"
exit 0
awk instead.