Skip to main content
Question

Script to delete static groups (by name or ID)

  • December 3, 2020
  • 1 reply
  • 0 views

RDowson
Forum|alt.badge.img+9

I have a number of static device groups that I need to delete (about 500 groups!).
I have all of the exact group names and the group ID's.
Could someone please help me with a script to load in these names or IDs and delete them in a batch?

Thanks in advance!

1 reply

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • December 4, 2020

Something along these lines perhaps? Not tested, but it should work or just need some tweaks.
You will need to of course update the relevant bits like the API username/password and the correct URL. If these are computer groups and not mobile ones, then use computergroups instead of mobiledevicegroups

#!/bin/sh

user="username"
pass="password"
url="https://your.jamfserver.com/JSSResource/mobiledevicegroups/id"

group_ids=(1 3 5 10 12 13 18 20 21 28 35). ## Put all IDs in this array separated by spaces

for ID in "${group_ids[@]}"; do
    echo "Now deleting group id: ${ID}"
    /usr/bin/curl -u "${user}:${pass}" "${url}/${ID}" -X DELETE
done

Alternatively, if the group IDs are all in a file somewhere, you could point the script to that file to read them in instead and loop over each one to delete them.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings