Setting the asset tag to the match the computers name

stats193
New Contributor

Recently joined a company whose computers don't have the asset tag field named, does anyone have a script to do this?

Really don't facing manually naming each one

4 REPLIES 4

mahughe
Contributor

give this a try..

https://www.jamf.com/jamf-nation/discussions/18944/setting-ard-info-fields-dynamically-from-the-jss

GabeShack
Valued Contributor III

Since we use the barcode in the computer name which is like "Building-StaffPosition-Barcode or HS-Teacher12345" I do this:

#!/bin/sh

#1st get computer name#
COMPNAME=`/usr/sbin/scutil --get ComputerName`

#2-grab the last 5 characters#
vasset=${COMPNAME:(-5)}

#3-set the asset in JSS#
jamf recon -skipApps -skipFonts -skipPlugins -assetTag $vasset

Gabe Shackney
Princeton Public Schools

Gabe Shackney
Princeton Public Schools

GabeShack
Valued Contributor III

Id also say once you have the fleet enrolled with assigned asset tag info, I'd now just dump it into the PreInventory csv so it would automatically get it going forward without any needed scripting.

Gabe Shackney
Princeton Public Schools