Posted on 02-14-2018 09:23 AM
Looking for a computer naming script to pull information from the General Field within each computers record in JAMF. User and Location = Building, From the General tab = Asset Tag, Model - from the hardware tab. Is this possible? Can someone share something close to it please? Thanks
<Building><Model><Asset Tag>
Posted on 02-14-2018 09:52 AM
It sounds like you need an API script to pull these strings, yes? I'm not clear on the end purpose of it, but, does something like this get you most of the way there?
#!/bin/bash
apiUser="apiaccount"
apiPass="apipassword"
jssURL=$(defaults read /Library/Preferences/com.jamfsoftware.jamf.plist jss_url)
macUDID=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformUUID/{print $4}')
macData=$(curl -H "Accept: application/xml" -sfku "${apiUser}:${apiPass}" "${jssURL}JSSResource/computers/udid/${macUDID}/subset/general&location&hardware")
macBuilding=$(xpath '/computer/location/building/text()' <<< "$macData")
macAssetTag=$(xpath '/computer/general/asset_tag/text()' <<< "$macData")
macModel=$(xpath '/computer/hardware/model/text()' <<< "$macData")
echo "Building = $macBuilding"
echo "Asset Tag = $macAssetTag"
echo "Model = $macModel"
You will need to replace the apiUser and apiPass strings with either hardcoded values, or use script parameters passed to them for the credentials.
Posted on 04-30-2018 01:50 PM
@jgwatson did you ever get this working? I have an almost identical need as this. Just curious what you came up with.
Posted on 07-13-2018 01:42 PM
@mconners really sorry for the late reply - no dice I'm afraid. Gave up on it.