Mass Delete Using Serial Number List?

musat
Contributor III

Hello,

We are in the process of selling many of out 8th grade MacBooks to the students. We are marking them sold in our cataloging system and have run the removeframework (along with many other tasks), but we never figured out how to script deleting the device from the JSS. Using our cataloging system I can create a list of serial numbers for the devices to delete. Is there some way to use this list of serial numbers to automate deleting the devices? My quick look didn't reveal anything, but figured I would check.

Thanks,
Tim

1 ACCEPTED SOLUTION

brad
Contributor

HI @musat,

@thoule has a nice solution there. Another option would be to take your serial numbers and format them to be serial, serial, serial, serial and paste that into the search field. That will list all the devices and then you can do a mass action. This gives you a sanity check of sorts before deleting devices.

I use that method or another method where I add the devices to a group using the API, then do the mass action to delete when ready.

Cheers!

Brad

View solution in original post

11 REPLIES 11

thoule
Valued Contributor II

Assuming you have a text file with serial numbers such as:

QW123456FED FED2353RB21A ABCDEFG1234
#!/bin/sh
#deletes computers identified by SNs in a text file

username="apiusername"
password="SekretWurdz"
server="https://server.name.com:8443"

computerList=`cat /Users/<yourname>/Desktop/SNsToDelete.txt`
arr=($computerList)

for i in "${arr[@]}"; do
    echo "Deleting computer: $i"
    curl -H "Accept: application/xml" -sfku "$username:$password" "$server/JSSResource/computers/serialnumber/$i" -X DELETE 
done

brad
Contributor

HI @musat,

@thoule has a nice solution there. Another option would be to take your serial numbers and format them to be serial, serial, serial, serial and paste that into the search field. That will list all the devices and then you can do a mass action. This gives you a sanity check of sorts before deleting devices.

I use that method or another method where I add the devices to a group using the API, then do the mass action to delete when ready.

Cheers!

Brad

mm2270
Legendary Contributor III

@brad thanks for your post. That's an amazing hint!! I never knew you could type/paste in multiple serial numbers separated that way and pull them all up at once. How long has that been a feature that I never knew about!? And I see this also works for computer names! Sweet! I wonder what else it works with? Need to go off and experiment now...

musat
Contributor III

Thanks for the ideas. I wound up using the suggestion from @brad and did a search on serial number. Which wound up being a very good idea. I has a list of 267 serial numbers, and the search turned up 282 computers. Guess I need to do my duplicate hunt again.

cdenesha
Valued Contributor III

That is SWEET! Thanks @brad for posting and JAMF for coding! This will be useful for many things..

areiskis
New Contributor

@brad - This just saved me a couple hours. Thank You!

nicole_qu
New Contributor II

Thanks @brad , search serial numbers is great method. However, when we try bulk delete around 150 computers, the action times out, and CPU goes really high. We are using Jamf 10.3.1 on premise. Is this an known issue, or something I did was wrong? Any suggestions? Thanks again.

emily
Valued Contributor III
Valued Contributor III

@nicole.qu I realize I'm not @brad, but you're running into a PI that is resolved in 10.6.

[PI-004957] Fixed an issue that caused intermittent performance issues when a mass action was used to delete computers.

belldesean
New Contributor III

I recommend using a Static Group to perform this request. I just deleted 53 mobile devices from our JAMF in less than a couple of minutes. I created a static group with the help of The MUT. You can create one in JAMF too but if you have a list of serial numbers I think it's much easier with The MUT. I then click on the Static Device Group > View > Action > Delete Mobile Devices > Are you sure? > Yes.

Here is a link to the Jamf Pro Administrator's Guide Version 10.5.0 that explains how to create a Static Device Group. I highly recommend making this feature your friend. (https://docs.jamf.com/10.5.0/jamf-pro/administrator-guide/Static_Device_Groups.html)

cmpatterson
New Contributor II

I tried to find by pasting many serial numbers separated by a comma and was not able to find any (sorry for being dense). Where exactly did everyone "paste" the serial numbers?

I created a "smart Group" because they all had the same position and I was able to delete 93 ipads that way.

Jamaduri88
New Contributor

Is there a possibility to wipe computers instead of delete computers in a Smart Group?