Add Asset Tag from "Info 1" field"

jonathanla
New Contributor III

We enter our asset tag numbers into the "info 1" field in the Sharing/Remote Management/Computer Settings window. How can we get these to show up in the Asset Tag field in Casper?

Also, some of the fields are already have asset tag numbers in there, probably from someone manually entering them in Casper.

thanks.

4 REPLIES 4

jrserapio
Contributor

I use a self service policy to get the Asset tags into the JSS. Im sure you could use something similar. I believe i found the script on JN. Have a jamf helper script to pop up prior.
The main thing you are looking for is jamf recon -assetTag <asset tag #>

osascript -e 'tell application "System Events" to set visible of process "Self Service" to false'

asset=$(/usr/bin/osascript <<-'__EOF__'
tell application "System Events"
  activate
  set input to display dialog "Enter Asset Number: " default answer "" buttons {"OK"} default button 1
  return text returned of input as string
end tell
__EOF__
)

jamf recon -assetTag $asset

JH=/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper
TITLE="GROUP NAME"
ICON="ICON Location"
ADESC="Natural"


"$JH" -windowType utility -title "$TITLE" -heading "Asset Tag" -description "Asset Tag has been successfully added to the JSS computer record." -button1 "Proceed" -icon "$ICON" -alignDescription natural -alignHeading natural

exit

jonathanla
New Contributor III

Appreciate the reply. At this point we're not ready to have our employees interact with a pop up. I was looking more for a solution for us to pull data from that particular field automatically.

mm2270
Legendary Contributor III

Take a look at this thread:
https://jamfnation.jamfsoftware.com/discussion.html?id=13233

On there its discussed how to read back the value of the ARD fields, like Text1, Text2, etc. Specifically, something like this:

/usr/bin/defaults read /Library/Preferences/com.apple.RemoteDesktop Text1

Store that in a variable and then use it in a recon to set the asset tag.

#!/bin/sh

ARDField1=$(/usr/bin/defaults read /Library/Preferences/com.apple.RemoteDesktop Text1)

/usr/sbin/jamf recon -assetTag "$ARDField1"

jonathanla
New Contributor III

Thanks. That's what I'm looking for.