Mass delete all classes Imported with Apple School manager
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
01-29-2018
02:20 PM
- last edited
Tuesday
by
kh-richa_mig
We are after changing the naming convention for classes imported with ASM. Is there a way to mass delete the classes in there now?
Thanks
- Labels:
-
Configuration Profiles

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-30-2018 11:27 AM
You can use the SIS Importer to delete all existing classes. You'll just need to create an export with no source file and the "Delete Existing Classes" box checked. It takes a while for it to delete them all, depending on how many classes you have, but this is the easiest way to delete all of the classes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-26-2018 03:17 PM
Is this still the best way to delete classes? I need to delete 1400 or so. So this looks very appealing. I am running 10.5, will this work with it? I was given a script by Jamf to do it and it won't run for some reason. Something about special characters in the password.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-27-2018 09:13 AM
@hhiggins I did this recently myself via a short script, worked very well after discovering that the api does not like some special characters in passwords. Find the classid for the ones you wish to delete using the get /classes from the Jamf API. Plug those start and end IDs in where the script specifies for n
!/bin/bash
jssUser="Username"
jssPass="Password"
jssURL="https://yourdomain.jamfcloud.com:443/"
for n in {1..100}
do
curl -kvu $jssUser:$jssPass ${jssURL}JSSResource/classes/id/$n -X DELETE
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-09-2018 10:11 AM
We delete all classes each summer and I still use the SIS Importer using the method described above by bburdeaux. It's easy to use and consistently works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-08-2019 11:45 AM
I tried this, but got this message: "Connection finished: 0 of 1 plug-ins were successful" and no classes were deleted. I've attached screenshots. Any help greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-08-2019 12:02 PM
Never mind. I got it to work. I had to add port 443 to the URL because if I didn't it kept defaulting to 8443 when I saved it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-13-2019 10:08 AM
@cboatwright script working great for us. Had to fix the shebang and change 443 to 8443 in our environment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-27-2019 04:53 PM
i am able to delete all classes by using sis importer.
The second and after sync with ASM didn't import any classes .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 11-21-2019 09:07 AM
We ended up using DbVisualizer Pro and a single line query to get this done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-27-2021 06:43 AM
Hello,
Can you please share what is the query you used to delete all classes
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 01-10-2020 11:45 AM
@cboatwright For those that might find it useful I modified your code above so that you don't have to determine the range of your classes. This will automatically find the IDs of all the classes you have created and delete all of them. Be careful with this as it will delete everything, but, I've found it really useful as a quick way to clear everything out before re-importing from ASM.
#!/bin/bash
jssUser="Username"
jssPass="Password"
jssURL="https://yourdomain.jamfcloud.com:443/"
echo "Downloading list of class IDs..."
ids+=($(curl -X GET -s -k -u "$jssUser:$jssPass" "$jssURL/JSSResource/classes" | xmllint --format - | awk -F'>|<' '/<id>/{print $3}' | sort -n))
for n in "${ids[@]}"; do
curl -kvu $jssUser:$jssPass ${jssURL}JSSResource/classes/id/$n -X DELETE
done

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-01-2020 07:50 AM
It is that time of year again, and just thought I would chime in with some updates on this process! I have now tried @RPSadmin script (works great for those wanting to simply delete all!) and the SIS Importer tool. Unfortunately it seems the SIS Importer tool does not like macOS Catalina, and possibly Mojave too - good thing it is Java-based so I just dumped it on my PC and started running from there.
Here is where I met my roadblock this year - SIS Importer and scripts both ran "successfully" but my 6000 classes were not going away! Finally I logged into the local admin service account we use for these things (and when LDAP is down) where I noticed it was in site view for just 1 of our schools. I switched it to full view, fired up SIS Importer again and low and behold it actually began deleting classes! That's just nuts... but not more nuts than Jamf STILL NOT having this functionality built-in!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-01-2020 12:09 PM
We use both ASM created classes (primarily in upper grades) as well as manual ones (in lower grade class sets). I've modified the above script to check each class for its source, and if source = N/A skips it, while deleting any classes with a source of "Apple School Manager". There is probably a better way to do this, but this does seem to work.
#!/bin/bash
jssUser="apiUser"
jssPass="apiPassword"
jssURL="https://your.jamf.url:8443"
echo "Downloading list of class IDs..."
ids+=($(curl -X GET -s -k -u ${jssUser}:${jssPass} ${jssURL}/JSSResource/classes | xmllint --format - | awk -F'>|<' '/<id>/{print $3}' | sort -n))
for n in "${ids[@]}"; do
source=$(curl -X GET -s -k -u ${jssUser}:${jssPass} ${jssURL}/JSSResource/classes/id/${n} | xmllint --format - | awk -F'>|<' '/<source>/{print $3}')
if [[ $source = "N/A" ]] ; then
echo "Class $n manually created, skipping..."
elif [[ $source = "Apple School Manager" ]] ; then
echo "Class $n created by ASM, deleting..."
curl -s -k -u ${jssUser}:${jssPass} ${jssURL}/JSSResource/classes/id/${n} -X DELETE
fi
done
exit 0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2021 11:16 AM - edited 08-05-2021 12:48 PM
JamfCloud Version 10.30.3
and running it on a Big Sur laptop....
I would like to delete my 900+ ASM classes but leave my manual classes intact.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2021 11:52 AM - edited 08-05-2021 12:46 PM
Ran below (subbing in my user, PW and URL)
and got this return:
Downloading list of class IDs...
-:10: parser error : Opening and ending tag mismatch: br line 8 and p
</p>
^
-:11: parser error : Opening and ending tag mismatch: p line 8 and body
</body>
^
-:12: parser error : Opening and ending tag mismatch: body line 5 and html
</html>
^
-:12: parser error : Premature end of data in tag html line 1
</html>
#!/bin/bash
jssUser=“username”
jssPass=“password”
jssURL="https://my.jamf.url:8443"
echo "Downloading list of class IDs..."
ids+=($(curl -X GET -s -k -u ${jssUser}:${jssPass} ${jssURL}/JSSResource/classes | xmllint --format - | awk -F'>|<' '/<id>/{print $3}' | sort -n))
for n in "${ids[@]}"; do
source=$(curl -X GET -s -k -u ${jssUser}:${jssPass} ${jssURL}/JSSResource/classes/id/${n} | xmllint --format - | awk -F'>|<' '/<source>/{print $3}')
if [[ $source = "N/A" ]] ; then
echo "Class $n manually created, skipping..."
elif [[ $source = "Apple School Manager" ]] ; then
echo "Class $n created by ASM, deleting..."
curl -s -k -u ${jssUser}:${jssPass} ${jssURL}/JSSResource/classes/id/${n} -X DELETE
fi
done
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 11-04-2020 09:26 AM
Tossing a PowerShell class deletion script in here as well. The Invoke-RestMethod
cmdlet in PowerShell makes working with xml and json pretty painless.
# Use the Jamf Pro API to delete all classes
$jssURL = "https://jamf.example.com:8443"
$ErrorActionPreference = "Stop"
$creds = Get-Credential
$url = "$jssURL/JSSResource/classes"
# Force TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$jamfClassesXml = Invoke-RestMethod -Uri $url -Credential $creds
Write-Host "$($jamfClassesXml.classes.size) classes found"
Write-Host "----------------------------------------"
$confirmation = (Read-Host 'Delete ALL Classes? (Y/N) [N]').ToLower()
if ($confirmation -eq 'y') {
foreach ($class in $jamfClassesXml.classes.class) {
Write-Host "Deleting class $($class.id)"
$return = Invoke-RestMethod -Uri "$urlid$($class.id)" -Credential $creds -Method Delete
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-17-2021 12:04 PM
hey! I am new to PowerShell and I am getting an "Invoke-Restmethod : Unable to connect to the remote server"
I have updated the commands for our JSS URL and credentials for our API account. Anything else I can try to fix it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-17-2021 12:10 PM
I'm not as savvy with powershell, but the port may be the issue...did you try 443 (instead of 8443)?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-17-2021 12:11 PM
thank you! that was the issue 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 12-07-2020 06:21 AM
Thank you, @cbrewer!
Working from home, and my Windows box is WAY faster than my Mac.
ASM munged everything, and created duplicate accounts with the same Roster associated, so I have to clean up about 50 user accounts. This will make it possible to do so in a few hours instead of a few days! Thank you again!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-13-2021 05:16 AM
I'm a complete newbie when it comes to scripting. I've been using the SIS import tool for years, but this year I cannot. How do I run the script proposed by @RPSadmin from my Mac? Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 11:26 AM - edited 08-17-2021 11:31 AM
Hi! I'm RPSadmin from above - the new push to jamf id seems to have forced me to create a new account - guess I'll have to figure out how to merge them 🙂
In any event, to answer your questions, you do the following to run the script on a mac
- Open text edit and create a new file.
- Go to Format > Make Plain Text
- Copy and Paste the script from above, don't forget the line that says "#!/bin/bash"
- Change the 2nd, 3rd, and 4th lines so that they show the correct username, password, and URL.
- Save the file and quit.
- Find the file and change the extension to .sh instead of .txt
- Open terminal and type in "sudo chmod u+x /path/to/file" swapping out "/path/to/file/" with the path to the file and excluding the quotation marks. Note that you can drag and drop the file into the terminal window in order to get the correct path, this is generally the easiest way to make sure it is correct.
- Hit enter. It should ask for your password, go ahead and enter it. You wont see it as you type, but it is being entered.
- Once complete drag and drop the file into terminal again, without sudo chmod u+x so that it just shows the path to the file. Hit enter and it should execute. If it doesn't work you may have to put sudo before the file path, but that shouldn't be necessary.
As I mentioned in the first post, just be careful doing this as it will wipe out all your classes in one go.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-17-2021 11:34 AM
Brilliant! Easy enough. Appreciate your help tremendously!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-29-2021 05:32 PM
This script worked beautifully. I have been going back and forth with jamf support all day and everything they send did not work. Thanks so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-07-2021 10:57 AM
Thanks for the steps, I greatly appreciate them. Unfortunately, I am getting a "-:1: parser error : Document is empty" error. Any thoughts on what this error means and how to resolve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-04-2022 05:42 PM
For some reason, I keep getting
***********
scrowell@SCROWELL-MBP ~ % sudo chmod u+x sudo /Users/scrowell/Desktop/DeleteAllClasses.sh
Password:
Sorry, try again.
*************
Not sure what's going on. My account authenticates to jamf through LDAP so I tried using a standard user in jamf that has admin privileges as well without luck. I first used my account in the SH file and the terminal prompt then I tried using the standard account. Any suggestions?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-04-2022 05:52 PM
What you’re doing with this step is changing your script permissions to be
executable. You’re using sudo on your computer so it wants your local user
password ( provided that user is a sudoer)
Hope this helps!
Sandy
--
Sandy Hinding (she/her)
iOS/OSX Systems Administrator
ISD # 197-West St. Paul-Mendota Heights-Eagan Schools
sandy.hinding@isd197.org
651-403-8400
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-04-2022 06:18 PM
Makes sense. I did that but accidentally screwed up the command and was prompted for the pwd. Then I did it properly (I think) but got no results. All of the classes are still present.
*********
scrowell@SCROWELL-MBP ~ % sudo chmod u+x sudo /Users/scrowell/Desktop/DeleteAllClasses.sh
Password:
chmod: sudo: No such file or directory
scrowell@SCROWELL-MBP ~ % sudo chmod u+x /Users/scrowell/Desktop/DeleteAllClasses.sh
scrowell@SCROWELL-MBP ~ % sudo chmod u+x /Users/scrowell/Desktop/DeleteAllClasses.sh
scrowell@SCROWELL-MBP ~ %
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 02-05-2024 10:37 AM
For anyone finding this thread in the year 2024 -
There was a small typo in my script above which wasn't causing issues before but is now. This is the corrected script:
#!/bin/bash
jssUser="Username"
jssPass="Password"
jssURL="https://yourdomain.jamfcloud.com:443"
echo "Downloading list of class IDs..."
ids+=($(curl -X GET -s -k -u "$jssUser:$jssPass" "$jssURL/JSSResource/classes" | xmllint --format - | awk -F'>|<' '/<id>/{print $3}' | sort -n))
for n in "${ids[@]}"; do
curl -kvu $jssUser:$jssPass ${jssURL}/JSSResource/classes/id/$n -X DELETE
done
Directions on how to implement the script remain the same, however. I'll reprint them here so everything is in one place:
- Open text edit and create a new file.
- Go to Format > Make Plain Text
- Copy and Paste the script from above, don't forget the line that says "#!/bin/bash"
- Change the 2nd, 3rd, and 4th lines so that they show the correct username, password, and URL.
- Save the file and quit.
- Find the file and change the extension to .sh instead of .txt
- Open terminal and type in "sudo chmod u+x /path/to/file" swapping out "/path/to/file/" with the path to the file and excluding the quotation marks. Note that you can drag and drop the file into the terminal window in order to get the correct path, this is generally the easiest way to make sure it is correct.
- Hit enter. It should ask for your password, go ahead and enter it. You wont see it as you type, but it is being entered.
- Once complete drag and drop the file into terminal again, without sudo chmod u+x so that it just shows the path to the file. Hit enter and it should execute. If it doesn't work you may have to put sudo before the file path, but that shouldn't be necessary.
As I mentioned in the first post, just be careful doing this as it will wipe out all your classes in one go.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-02-2024 05:54 AM
I am getting a "-:1: parser error : Document is empty" error. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-07-2024 07:09 AM
Hey @RPSadmin2, Thanks for the detailed directions. All seemed to be running smoothly, but when I run the sh file it just returns the response.
Downloading list of class IDs...
Then goes back to the command prompt. Its like nothing is running after printing that on the screen.
We are running JAMF Version11.3.0-t1707837736
Thanks,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-09-2024 10:19 AM
If you are not a local admin you want to run as follow in terminal
sudo sh and drag the script to terminal
(place the script file on your desktop before dragging…it didn’t work when I dragged it from google drive to terminal)
If you are an admin on your local machine run: (ADMIN ACCOUNT SHOULD BE STANDARD USER WITH ADMINISTRATOR PRIVILEGES AND PWD CANNOT HAVE SPECIAL CHARACTERS)
sh and drag script to terminal
The file I use is attached:
Suzanne Magnolia Crowell ’95
Director of Technology
Our Lady of Good Counsel High School
scrowell@olgchs.org
17301 Old Vic Blvd
Olney, MD 20832
p: 240.283.3220
OLGCHS.ORG<>
WE INSPIRE OUR STUDENTS TO EXCEL, SERVE, AND LOVE.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-09-2024 12:23 PM
Yes, unfortunately this script isn't working for me anymore either. I looked into it a bit and it seems like basic authentication is no longer supported, so it will need to be rewritten to support bearer authentication. Unfortunately I don't have time to re-write the script right now, however, this article seems to be a good starting point on how to tackle it: https://community.jamf.com/t5/tech-thoughts/how-to-convert-classic-api-scripts-to-use-bearer-token/b...
If I get a chance to circle back to this and fix what I wrote previously I'll update this thread, but I'm not sure when that will be....
