Auto-populating the Location info in the Casper JSS inventory
In the past year, my worksite began using Jamf Software‘s Casper Suite system management tool to manage our Macs. One of the great things about it is that it automatically pulls a ton of information about the managed machines. However, it wasn’t set up to automatically show me who was using a particular machine. There’s a Location category, where you can manually query your Active Directory or LDAP directory service and set who’s associated with which machine. However, the fact that the process was manual almost guaranteed it would be out-of-date within a fairly short period of time. As a workaround, I set up an Extension Attribute that showed me who was the last reported user, but I wasn’t really happy with it. I had also set up the Building attribute to automatically update by setting the Building value to correspond to particular IP subnets.
There the situation stayed for a few months. I wasn’t particularly happy, but not unhappy enough to go through and update manually. Fortunately, a thread appeared on the Casper mailing list about this particular topic. After taking a look at the various scripts that were posted in response, I was able to adapt my own from the one that Ben Toms shared. It’s using dscl to query the AD plug-in on my Macs to get information on the currently logged-in user.
From there, I uploaded the script to my JSS and set up a policy to run it once a day.
Final result? I was able to go from this:
To this (some information redacted):
Muuuch better. For those who want the script, I have it posted here on my GitHub repo.