Hello you could use that script :
#!/bin/sh
jamfUrl=""
jamfUser=""
jamfPass=""
#Set my csv location
Building_CSV="$HOME/Desktop/Building.csv"
#For each line of the CSV File
while read line; do
#Get the List of existing Building
Building_Already_Existing=$(curl -sku $jamfUser:$jamfPass -H "Accept: application/xml" $jamfUrl/JSSResource/buildings | xmllint --format - | grep "<name>" | awk 'BEGIN{FS=">|<"} {printf "%s;", $3}')
#Check if the Building is not in the existing Building List
if [[ $Building_Already_Existing != *"$Building_Name;"* ]]; then
Echo "Building : $Building_Name : not existing in Jamf, creation !"
#Create the Building
curl -sku $jamfUser:$jamfPass -H "Content-type: application/xml" $jamfUrl/JSSResource/buildings/id/0 -X POST -d "<building><name>$Building_Name</name></building>"
else
#Else do nothing
Echo "Building : $Building_Name : Already exist"
fi
done < $Building_CSV
exit
I'll give that ago - thanks :)
I have updated the script on the Jamf GitHub repo, which should resolve the issue. If there are any additional issues, let me know or open an issue on GitHub. On a related note, I'll be taking a closer look at the other API scripts within that repo in the coming weeks.