via the API... do a GET for asset_tag... cycle it through all the computer_id's... store that info in a temp .csv document then put it from the temp document into the asset tag field of choice...
so the logic would be...
curl -kvu https://yourJSS.com:8443 -T GET > /temp/asset_tag_and_computer_id.csv
read from /temp/asset_tag_and_computer_id.csv
curl -kvu https://yourJSS.com:8443 -T POST
An alternative, also using the API, you could set up a script to run in a one time policy against each Mac to use an API account to pull its own asset tag, store that into a variable, and then pipe that back into a ARDAgent kickstart command to set field 4 for that Mac.
Here's a framework for this. The below should work with either version 8.x or 9.x of Casper suite, since they both can use the MAC address as an item to locate a Mac in the db. Version 9 can also accept serial #, UDID and a few others. Version 8 was a little more limited.
#!/bin/bash
MACaddy=$( networksetup -getmacaddress en0 | awk '{print $3}' | sed 's/:/./g' )
echo "{MACaddy}"
ASSETTAG=$( curl -s -k -u apiuser:apipass https://yourjss.server.com/JSSResource/computers/macaddress/$MACaddy 2>&1 | xpath /computer/general/asset_tag[1] | awk -F'[>|<]' '{print $3}' )
echo "${ASSETTAG}"
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -computerinfo -set4 -4 "${ASSETTAG}"
Just customize the "apiuser", "apipass" and JSS server address items to your environment.
@mm2270 I had to add the port 8443 and $ but this works great thanks for posting.
#!/bin/bash
MACaddy=$( networksetup -getmacaddress en0 | awk '{print $3}' | sed 's/:/./g' )
echo "${MACaddy}"
ASSETTAG=$( curl -s -k -u apiuser:apipass https://yourjss.server.com:8443/JSSResource/computers/macaddress/$MACaddy 2>&1 | xpath /computer/general/asset_tag[1] | awk -F'[>|<]' '{print $3}' )
echo "${ASSETTAG}"
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -computerinfo -set4 -4 "${ASSETTAG}"
Awesome peeps!!!
Works like a charm!
Thank you very much,
-pat