API - Deleting Mobile Devices, by serial number, from a list?

btaitt
Contributor

Hey all,

I'm just starting to familiarize myself with the API, but I don't know where to start with this.

We're going to be trading ~1200 iPads in the next month. I need to delete the old 1200 from JSS, and I have the serial numbers of the devices that I need to delete.

Is there a way for the API to reference something like a .csv file with serial numbers, then delete those mobile devices from JSS?

1 ACCEPTED SOLUTION

techhelprhs
New Contributor III

I am not in a position to test this properly. So, please use at your discretion and test it thoroughly before looping through all of the serials. But, this should work... Create a txt file with one serial number per line. Press return or type something one line below the last serial number (the script will omit the last line of the txt file).

I use something similar to image, configure and then delete machines that are not going to be managed.

Best,

-Chris

#!/bin/sh
NUMBERS="/path/to/file.txt"

/bin/cat $NUMBERS | while read SERIAL; do
/usr/bin/curl -X DELETE -u username:password https://your.jss.server:8443/JSSResource/mobiledevices/serialnumber/$SERIAL 2>/dev/null
done

exit 0

View solution in original post

4 REPLIES 4

techhelprhs
New Contributor III

I am not in a position to test this properly. So, please use at your discretion and test it thoroughly before looping through all of the serials. But, this should work... Create a txt file with one serial number per line. Press return or type something one line below the last serial number (the script will omit the last line of the txt file).

I use something similar to image, configure and then delete machines that are not going to be managed.

Best,

-Chris

#!/bin/sh
NUMBERS="/path/to/file.txt"

/bin/cat $NUMBERS | while read SERIAL; do
/usr/bin/curl -X DELETE -u username:password https://your.jss.server:8443/JSSResource/mobiledevices/serialnumber/$SERIAL 2>/dev/null
done

exit 0

View solution in original post

mmcallister
Contributor II

If there are any criteria (Model perhaps?) that you could use to build a device group, you could then delete the entire group of devices at once.

btaitt
Contributor

@techhelprhs I finally had a chance to try this out with some devices we resold, and it worked beautifully! Thank you so much!

techhelprhs
New Contributor III

Glad to help!

-Chris