Skip to main content

Hi-

So I keep track of computers' asset tag numbers in Casper. Right now it's a manual process whereby I ask the user what their asset tag number is and then I plunk it into Casper. We're going to be going to production soon and this would require a lot of manual overhead on my (or any other admin's) part. Ideally, I'd like to prompt the user for this information and then store it in Casper. I know how to prompt a user on the command line (e.g. Use a script for this), store it and then write it out to a dummy receipt file, but I'd like it to look better. What's the best way to do this? I could make an AppleScript studio app to do it, but I don't know if that's the best way. I don't know any cocoa, but I have a feeling that would be the best way to go - perhaps that'd be a good "first app" to create?

Thoughts?

j
---
Jared F. Nichols
Desktop Engineer, Infrastructure and Operations
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

do you use the asset tag anywhere in the image? for example we use the
asset tag as part of the computer name, so I would be easily scriptable
from that perspective. Do you guys log the asset tags anywhere?



Thomas Larkin
TIS Department
KCKPS USD500
tlarki at kckps.org
blackberry: 913-449-7589
office: 913-627-0351


Currently we have zero naming convention, but that may or may not change in the future. If it does, asset tag will likely be incorporated into the machine name, thus negating my need to track it. However, I'm not relying on anything changing (this is Government after all :) ) and I'd like to get this set up.

Some folks do name their machines with their asset tag number (bless them) though this is more rare. All I really want to do is prompt a simple box that asks for the asset tag number with a clear and OK button. On OK, it'll do a touch /Library/Application Support/JAMF/Recipts/$assettag.pkg so it'll show up as a receipt in Casper. Then I can plunk in the number easily.

Would there be a way to perform a database write function to make this happen to take the manual interaction out completely?

j


We use the asset tag in our naming convention

Example: CS-123456

Below is the script that simply grabs the last 6 characters and populates this into casper. The script is set to run at reboot so the name has already been set when imaging.

#!/bin/sh
COMPNAME=/usr/sbin/scutil --get ComputerName
echo "jamf recon -assetTag ${COMPNAME:(-6)}"
jamf recon -skipApps -skipFonts -skipPlugins -assetTag ${COMPNAME:(-6)}

Cheers,

-Adam

Adam Shepard
Creighton School District
Web Developer / System Administrator
[Office 602-381-6000][Cell 602-319-8935]


I have a similar need here. Most of the computers in my network are named with the asset tag, but there are a few that are not. However, I do have a spreadsheet matching up my serial numbers to my asset tags. Is there a way to import that data into the database. I was told it might be possible using the API, but I'm not familiar with how that functions. Any help would be appreciated.


Does anyone know how to use a script in updating "Location" of the machine? We currently use user ID and AssetTag for computer naming convention. Thanks to Adam we have the ability to input the asset tag in to jamf recon but I don't know if there is a command for submitting a userID and having it check and populate the fields?


Does anyone know how to use a script in updating "Location" of the machine? We currently use user ID and AssetTag for computer naming convention. Thanks to Adam we have the ability to input the asset tag in to jamf recon but I don't know if there is a command for submitting a userID and having it check and populate the fields?


The link to the Casper mailing list isn't working now, but there was a thread on automatically updating the Location information a few months back.

I made a post to my blog on what I did to get the Locations information automatically updated in our JSS, using the AD plug-in on our Casper-managed Macs:

http://derflounder.wordpress.com/2011/12/05/auto-populating-the-location-info-in-the-casper-jss-inventory/

I've also got the script posted to my GitHub repo:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/Casper_Scripts/jss_location_lookup


Hi Jared

I've created this AppleScript around PERL so you can upload it and create a policy with:
Triggered By: login
Execution Frequency: once per user

You will need to make some changes to suit your needs.
Let me know if you need further assistance.
Regards

#################

#!/usr/bin/perl

#check if Finder is running i.e. someone is loggged in.
if (ps -eA | grep "Finder" | grep -v grep) {
#call the AppleScript
system (qq|osascript -e '$script'|);
}
else {
# No Finder, so nobody logged, do nothing
}

$script=qq|
set myMessage to "What is your Asset Tag?" -- message to the user
set myCommand to "touch ~/Desktop/" -- path to where the file will be written, check permissions to the path. JAMF is read only!

tell application "System Events" activate display dialog myMessage default answer "" buttons {"OK", "Cancel"} default button 1 copy the result as list to {text_returned, button_pressed} set assetTag to the text_returned set myCommand to myCommand & assetTag as text do shell script myCommand
end tell
|;

#################


EDIT## \\- the script works as advertised and it prompts the user for proper input.

This is something I had whipped up but doesn't quite work. I am not sure how to pass the variable theAnswer into the do shell script command. Otherwise, it does work.

#!/bin/bash

# use apple script and bash to get input from user to update asset tags in the JSS
# by Tom Larkin
# proof of concept, no warranty given, use at own risk

# get user input from Apple Script and try to redirect output back into bash and user recon to update the JSS

/usr/bin/osascript <<-AppleScript

tell application "Finder"
    activate
    display dialog "Enter your asset number" default answer "Enter your asset tag number here"
    set theAnswer to (text returned of result)
    set cmd to "/usr/sbin/jamf recon -assetTag " & theAnswer
    do shell script cmd
end tell

AppleScript


exit 0

If someone can tell me how to fix this I'd appreciate it.


set theAnswer to (text returned of result)
set cmd to "/usr/sbin/jamf recon -assetTag " & theAnswer
do shell script cmd

should do it for you i think


set theAnswer to (text returned of result) set cmd to "/usr/sbin/jamf recon -assetTag " & theAnswer do shell script cmd should do it for you i think

You sir, are a genius, it works. Making changes to reflect the working method. Also, I did this as a bash script so it would run as root easier instead of using the Apple Script method of running commands with super user privileges.

My asset tag was in fact changed in the JSS to the input I put in.


@tlarkin nad @nessts Hey buddy i am fairly new to scripting and i am having a hard time to create a script to ask the user for their asset tag of their machine to capture and sent it back to the JSS. I am trying to cut out the manually process of seeking at out all the asset tags and going back and entering them in myself in selfservice. This way i can have it ask during the enrollment process and for machines already in the wild put it in selfservice as a once per computer policy to ask the user. By any chance can you shed some light on a script for this and working on the new 9.8 JSS ?


Try this jssmut.weekly.com


We use The MUT [http://jssmut.weebly.com/](link URL)


I stuck the script in a Self Service policy, and that will run as root. It will not ask for any authentication at all. It just runs. The Asset Tag is updated in less than a minute.


@ralphaelhollins this thread is ancient, it is actually an ancient archive from the old school mailing list before jamf nation ever even existed. In 2009 the current OS was 10.6 (Snow Leopard, some still argue how it was the best OS ever) and things have changed so much in Catalina from then.

I bet that applescript probably breaks all the new TCC/PPPC stuff in 10.14+ and no longer works. If you still want to use Applescript dialog boxes, many have had better luck with taking the tell application part of of the scripts out and instead just used display dialog and that seems to keep TCC/PPPC gremlins happy.

I really wish the mailing list posts would just be archived


The concept of the asset tag to me is useless when it comes to Apple devices (though we still use them - not my choice) in DEP. Location, user assignments, etc are all available in Jamf Pro and are easily exportable.


We used to use asset in name but when we moved to jamf we just switched to serial number only. This is the only information that can ever be a zero touch as it can be scripted to pick it up from the machine itself. Script at startup resets it to serial in case any user changes it. During dep screen, it displays a box for a tech to put in asset tag (optional but preferred), a description such as Person Name or office number (optional).


We use Asset Tags and we have our reseller slap them on, and we get CSVs at purchase that include this data, and it goes right into Service Now directly via API integration. From that point, if I wanted to, I could just grab the asset tags from Service Now and then toss them into jamf, but there is little value to put that data in jamf.