Posted on 05-04-2009 10:10 AM
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
Posted on 05-04-2009 10:32 AM
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?
Posted on 05-04-2009 10:39 AM
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
Posted on 05-04-2009 11:12 AM
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]
Posted on 01-24-2012 12:21 PM
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.
Posted on 01-24-2012 12:31 PM
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?
Posted on 01-24-2012 12:31 PM
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?
Posted on 01-24-2012 12:45 PM
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:
I've also got the script posted to my GitHub repo:
Posted on 02-09-2012 04:14 AM
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
|;
#################
Posted on 02-09-2012 10:16 AM
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.
Posted on 02-09-2012 10:19 AM
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
Posted on 02-09-2012 10:30 AM
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.
Posted on 09-17-2015 04:15 PM
@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 ?
Posted on 06-15-2016 08:00 AM
Try this jssmut.weekly.com
Posted on 06-23-2017 09:50 AM
We use The MUT [http://jssmut.weebly.com/](link URL)
Posted on 12-27-2019 09:21 AM
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.
Posted on 12-27-2019 08:48 PM
@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
Posted on 12-28-2019 10:28 AM
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.
Posted on 12-29-2019 01:49 PM
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).
Posted on 12-30-2019 09:42 AM
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.