Skip to main content

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

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

  1. Open text edit and create a new file.
  2. Go to Format > Make Plain Text
  3. Copy and Paste the script from above, don't forget the line that says "#!/bin/bash"
  4. Change the 2nd, 3rd, and 4th lines so that they show the correct username, password, and URL.
  5. Save the file and quit.
  6. Find the file and change the extension to .sh instead of .txt
  7. 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.
  8. 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.
  9. 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.


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?


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?


Hi,

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
Hi,

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

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 ~ %


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:

  1. Open text edit and create a new file.
  2. Go to Format > Make Plain Text
  3. Copy and Paste the script from above, don't forget the line that says "#!/bin/bash"
  4. Change the 2nd, 3rd, and 4th lines so that they show the correct username, password, and URL.
  5. Save the file and quit.
  6. Find the file and change the extension to .sh instead of .txt
  7. 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.
  8. 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.
  9. 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.

 


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:

  1. Open text edit and create a new file.
  2. Go to Format > Make Plain Text
  3. Copy and Paste the script from above, don't forget the line that says "#!/bin/bash"
  4. Change the 2nd, 3rd, and 4th lines so that they show the correct username, password, and URL.
  5. Save the file and quit.
  6. Find the file and change the extension to .sh instead of .txt
  7. 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.
  8. 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.
  9. 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.

 


I am getting a "-:1: parser error : Document is empty" error.  Any ideas?

 


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:

  1. Open text edit and create a new file.
  2. Go to Format > Make Plain Text
  3. Copy and Paste the script from above, don't forget the line that says "#!/bin/bash"
  4. Change the 2nd, 3rd, and 4th lines so that they show the correct username, password, and URL.
  5. Save the file and quit.
  6. Find the file and change the extension to .sh instead of .txt
  7. 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.
  8. 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.
  9. 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.

 


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


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


These are the directions I have:



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.

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


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/ba-p/273910

 

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....