Inventory Preload and script no longer working

stephaniemm77
Contributor II

Good Morning

So we have been using a .csv inventory preload with a script since we set up jamf a number of years ago, all of a sudden it is no longer renaming the computers properly. It is used to rename the machine to the asset tag, the asset tag shows up correctly in the jamf inventory if i do a search but it just will not rename.

When the policy runs it says its completed, so i don't even have an error to research. I have no idea what has changed. I have checked the account username/password, tried deleting data from the preload and re-uploading a new sheet. What am i missing here

Here is the script we are using.

#!/bin/bash

## Enter the API Username, API Password and JSS URL here
apiuser="account"
apipass="password"
jssURL="https://quinnipiac.jamfcloud.com"

## Get the Mac's UUID string
UUID=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformUUID/{print $4}')

## Pull the Asset Tag by accessing the computer records "general" subsection
Asset_Tag=$(curl -H "Accept: text/xml" -sku "${apiuser}:${apipass}" "${jssURL}/JSSResource/computers/udid/${UUID}/subset/general" | xmllint --format - 2>/dev/null | grep asset | sed -e 's/<[^>]*>//g')

echo "$Asset_Tag"

# Set Computer Name
sudo scutil --set HostName ${Asset_Tag}
sudo scutil --set LocalHostName ${Asset_Tag}
sudo scutil --set ComputerName ${Asset_Tag}

# Update Inventory
sudo jamf recon

6 REPLIES 6

jamf-42
Valued Contributor II

That script will no longer work. You need to have a bearer token and really it's considered 'a bad idea' to run API calls from the endpoint. 

jamf-pro-api-overview

sdagley
Esteemed Contributor II

@stephaniemm77 If your JSS instance has been updated to 11.5 then Basic Auth has been disabled, and you need to re-write your script to use Bearer Token auth instead of Basic Auth. See this post for an example: https://community.jamf.com/t5/jamf-pro/bearer-token-api-and-adding-computer-to-static-group/m-p/2669...

Great, I have no idea how to do this. I am not good with scripting at all. I guess I will go back to manually changing names. 

sdagley
Esteemed Contributor II

Learning some scripting would be highly recommended, but you might want to check out "The MUT" (Multi-Update Tool): https://github.com/jamf/mut

Yeah i wish i had the time to learn scripting, i will do that between my naps HAHA

Trying to use the MUT tool, filled out the spreadsheet and submitted it, says complete but didn't actually change anything.