Monday
Im looking for a way to use the API to bulk delete computers by serial number.
Im not seeing a way in the API to do this any more other than with device ID.
So does any one know of a way I can find the device ID based on the serial number ?
I know this gets the device deleted if I can query the Device ID.
curl -X 'DELETE' "$jamfProURL/api/v1/computers-inventory/${jamfProID}" -H 'accept: application/json' -H "Authorization: Bearer ${token}"
Monday
You would need to loop through API commands. You need to pull all (or whatever range of) devices inventory records, from there you script can match SN's to ID's to run whatever other API commands you want.
Tuesday
Yeah I don't have an issue getting the loop to work, the issue is getting the JAMF ID by serial number
Tuesday
You should be able to loop through your serial numbers and do a GET on:
"$JAMF_SERVER_URL/api/v1/computers-inventory?filter=hardware.serialNumber%3D%3D$SERIAL_NUMBER"
and narrow down on the ID from those responses:
{
"totalCount": 1,
"results": [
{
"id": "470",
...
Tuesday
Hi @csmith122
Please check this script for deleting the device using serial number from a text file. It uses Jamf Classic API with OAuth.
https://gist.github.com/b7088bcef3b58f9ca88bac0085429a96.git
Please test it before running in Prod.
Thanks.
yesterday
This was a good help for a start, however the issue is this is deprecated now
deleteURL="${Jamf_URL}/JSSResource/computers/serialnumber/${serialNumber}"
i ended up finding a way to look up the device and then with some jq magic parse it to get the ID and then run the script via a ID delete.
Then a friend pointed out to me that you can delete machines in jamf pro UI by pasting a coma seperated search in your jamf pro search and then use the actions button at the bottom to delete machines.