Deleting Mobile Device Apps In Jamf Using The API and a CSV
- Noah Cunning
- Jul 24, 2020
- 1 min read
This script that will communicate with your Jamf Pro API to delete any Mobile Device Apps by ID that you specify in a CSV or TXT file.
Below is the code, fill our your server URL, username, password, and path to the file. I was using coderunner to execute this script and it worked for my needs.
#!/bin/bash
#Created by Noah Cunning. noahcunning.com
#Declare variables
server="https://your.jamfURL.com/JSSResource/" #Server name
username="username" #JSS username with API privileges
password="password" #Password for the JSS account
file="~/your/file" #Path to TXT or CSV
#Do not edit below this line ------
[ ! -f $INPUT ] && { echo "$file file not found"; exit 99; }
OLDIFS=$IFS
IFS=','
while read ID;
do
curl -X DELETE -u ${username}:${password} ${server}mobiledeviceapplications/id/$ID
done < $file
IFS=$OLDIFS
Below is a snippet of the method I used to tell the API which ID's I needed removed. You can get all of the ID numbers using the "Jamf Pro Summary" function in the settings of your Jamf Pro. Make sure that you select Mobile Device Apps as your criteria then create and download your information. You will need to play around inside Excel or your preferred work sheet editor to isolate just the ID Number of the mobile device app.
Example of TXT file:
84
159
363
362
347
71
Make sure there is a blank space on the final row as this will delineate the end of the file.
I hope this helps and works well for you.
Comments